purpose of TypeScript-specific Token values

32 views
Skip to first unread message

Ben Liblit

unread,
Oct 18, 2021, 11:09:41 AM10/18/21
to Closure Compiler Discuss
The com.google.javascript.rhino.Token enumeration includes several values that are specific to TypeScript. These are even preceded by a "// TypeScript" comment:
  • INTERFACE
  • INTERFACE_EXTENDS
  • INTERFACE_MEMBERS
  • ENUM
  • ENUM_MEMBERS
  • IMPLEMENTS
  • TYPE_ALIAS
  • DECLARE
  • MEMBER_VARIABLE_DEF
  • INDEX_SIGNATURE
  • CALL_SIGNATURE
  • NAMESPACE
  • NAMESPACE_ELEMENTS
My understanding is that Closure cannot parse TypeScript, and I find no code elsewhere in Closure that creates tokens with these values. So what is the purpose of these TypeScript-specific Token values? How are they used? Are they historical artifacts, or placeholders for future development? Are they still actively used (created) by some TypeScript parser that I am not seeing in the regular Closure source tree?

Thank you for any clarification,
Ben

rish...@google.com

unread,
Oct 18, 2021, 12:56:59 PM10/18/21
to Closure Compiler Discuss

These look like remnants of a previous (~2015) effort where JSCompiler earlier had some incomplete support for parsing TS syntax, translating it to its AST, and generating TypeScript source based on that AST. 

But the parser was not maintained to parse newer TypeScript features.

lha...@google.com

unread,
Oct 18, 2021, 2:39:47 PM10/18/21
to Closure Compiler Discuss
As far as I know, the Tokens are only still used in https://github.com/angular/clutz/tree/stable/src/main/java/com/google/javascript/gents (the GitHub repository is archived but this tool is still maintained and used inside Google).
Reply all
Reply to author
Forward
0 new messages