-
-
Save mizchi/910c351d0ca4d8603b59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module Foo { | |
export class Hoge { | |
name:string; | |
message:string; | |
constructor(); | |
f(str:string):string; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fs = require 'fs' | |
pj = require 'prettyjson' | |
eval fs.readFileSync('node_modules/typescript/bin/typescript.js').toString() | |
# programText = "class Foo { }" | |
# console.log process.argv[1] | |
programText = fs.readFileSync(process.argv[2]).toString() | |
tree = TypeScript.Parser.parse( | |
'dummy.ts', | |
TypeScript.SimpleText.fromString(programText), | |
# false, | |
true, | |
new TypeScript.ParseOptions(TypeScript.LanguageVersion.EcmaScript5, true)) | |
# firstChildKind = tree.sourceUnit().childAt(0).kind() | |
console.log pj.render tree.sourceUnit(), noColor:true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_data: 0 | |
moduleElements: | |
item: | |
_data: 0 | |
modifiers: | |
item: | |
_fullText: declare | |
tokenKind: 63 | |
_trailingTriviaInfo: 4 | |
moduleKeyword: | |
_fullText: module | |
tokenKind: 65 | |
_trailingTriviaInfo: 4 | |
name: | |
_fullText: Foo | |
tokenKind: 11 | |
_trailingTriviaInfo: 4 | |
stringLiteral: null | |
openBraceToken: | |
_fullText: | |
""" | |
{ | |
""" | |
tokenKind: 70 | |
_trailingTriviaInfo: 5 | |
moduleElements: | |
item: | |
_data: 0 | |
modifiers: | |
item: | |
_fullText: export | |
tokenKind: 47 | |
_leadingTriviaInfo: 16 | |
_trailingTriviaInfo: 4 | |
classKeyword: | |
_fullText: class | |
tokenKind: 44 | |
_trailingTriviaInfo: 4 | |
identifier: | |
_fullText: Hoge | |
tokenKind: 11 | |
_trailingTriviaInfo: 4 | |
typeParameterList: null | |
heritageClauses: | |
openBraceToken: | |
_fullText: | |
""" | |
{ | |
""" | |
tokenKind: 70 | |
_trailingTriviaInfo: 5 | |
classElements: | |
_data: 0 | |
nodeOrTokens: | |
- | |
_data: 0 | |
modifiers: | |
variableDeclarator: | |
_data: 0 | |
propertyName: | |
_fullText: name | |
tokenKind: 11 | |
_leadingTriviaInfo: 32 | |
typeAnnotation: | |
_data: 0 | |
colonToken: | |
tokenKind: 106 | |
type: | |
tokenKind: 69 | |
equalsValueClause: null | |
semicolonToken: | |
_fullText: | |
""" | |
; | |
""" | |
tokenKind: 78 | |
_trailingTriviaInfo: 5 | |
- | |
_data: 0 | |
modifiers: | |
variableDeclarator: | |
_data: 0 | |
propertyName: | |
_fullText: message | |
tokenKind: 11 | |
_leadingTriviaInfo: 32 | |
typeAnnotation: | |
_data: 0 | |
colonToken: | |
tokenKind: 106 | |
type: | |
tokenKind: 69 | |
equalsValueClause: null | |
semicolonToken: | |
_fullText: | |
""" | |
; | |
""" | |
tokenKind: 78 | |
_trailingTriviaInfo: 5 | |
- | |
_data: 0 | |
modifiers: | |
constructorKeyword: | |
_fullText: constructor | |
tokenKind: 62 | |
_leadingTriviaInfo: 32 | |
callSignature: | |
_data: 0 | |
typeParameterList: null | |
parameterList: | |
_data: 0 | |
openParenToken: | |
tokenKind: 72 | |
parameters: | |
closeParenToken: | |
tokenKind: 73 | |
typeAnnotation: null | |
block: null | |
semicolonToken: | |
_fullText: | |
""" | |
; | |
""" | |
tokenKind: 78 | |
_trailingTriviaInfo: 5 | |
- | |
_data: 0 | |
modifiers: | |
propertyName: | |
_fullText: f | |
tokenKind: 11 | |
_leadingTriviaInfo: 32 | |
callSignature: | |
_data: 0 | |
typeParameterList: null | |
parameterList: | |
_data: 0 | |
openParenToken: | |
tokenKind: 72 | |
parameters: | |
item: | |
_data: 0 | |
dotDotDotToken: null | |
modifiers: | |
identifier: | |
_fullText: str | |
tokenKind: 11 | |
questionToken: null | |
typeAnnotation: | |
_data: 0 | |
colonToken: | |
tokenKind: 106 | |
type: | |
tokenKind: 69 | |
equalsValueClause: null | |
closeParenToken: | |
tokenKind: 73 | |
typeAnnotation: | |
_data: 0 | |
colonToken: | |
tokenKind: 106 | |
type: | |
tokenKind: 69 | |
block: null | |
semicolonToken: | |
_fullText: | |
""" | |
; | |
""" | |
tokenKind: 78 | |
_trailingTriviaInfo: 5 | |
closeBraceToken: | |
_fullText: | |
""" | |
} | |
""" | |
tokenKind: 71 | |
_leadingTriviaInfo: 16 | |
_trailingTriviaInfo: 5 | |
closeBraceToken: | |
_fullText: | |
""" | |
} | |
""" | |
tokenKind: 71 | |
_trailingTriviaInfo: 5 | |
endOfFileToken: | |
_fullText: | |
tokenKind: 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment