typescript-parser.jsx
Synopsis
TypeScript parser for JSX
Code Example
; static const code = ''' class Greeter { greeting: string; constructor(message: string) { this.greeting = message; } greet() { return "Hello, " + this.greeting; } } '''; static : void { var syntaxTree = TypeScriptParser; console; }
Installation
$ npm install typescript-parser.jsx --save-dev
API Reference
There are many internal hidden API to access AST tree. This section includes some important class document. There are no complete document. See source code.
TypeScript.Parser
class
Parse script and return AST object.
parse(filename : string, code : string, isDeclearFile : boolean) : TypeScript.SyntaxTree
var syntaxTree = TypeScriptParser;console;
TypeScript.SyntaxKind
object
This class has enum values. These values are used for ISyntaxElement.kind()
.
Available name list is here.
var kind = TypeScriptSyntaxKindList; // 1var name = TypeScriptSyntaxKind1; // 'List'
TypeScript.SyntaxTree
class
Root class of AST tree. SourceUnitSyntax
is derived from ISyntaxElement
. You can access AST tree from here.
toJSON() : variant
sourceUnit() :
TypeScript.SourceUnitSyntax`
var syntaxTree = TypeScriptParser;console;
TypeScript.ISyntaxElement
class
All elements are derived from this class. This class provides methods to traverse AST tree.
kind() : int
childCount() : int
childAt(index: int) : TypeScript.ISyntaxElement
toJSON() : variant
You should cast from this class to any your needed class.
if node == TypeScriptSyntaxKindForStatement var forNode = node as __noconvert__ TypeScriptForStatementSyntax; var statement = forNodestatement;
Development
Repository
- Repository: git://github.com/shibukawa/typescript-parser.jsx.git
- Issues: https://github.com/shibukawa/typescript-parser.jsx/issues
Run Test
$ grunt test
Build Sample
# Build sample $ grunt build# Create typescript-parser.jsx from TypeScript's module $ grunt pre-build
Generate API reference
$ grunt doc
Author
- shibukawa / yoshiki@shibu.jp
License
Apache-V2
Complete license is written in LICENSE.md
.