Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript Language Specification #33275

Closed
fljmayer opened this issue Sep 6, 2019 · 8 comments
Closed

TypeScript Language Specification #33275

fljmayer opened this issue Sep 6, 2019 · 8 comments
Labels
Duplicate An existing issue was already created

Comments

@fljmayer
Copy link

fljmayer commented Sep 6, 2019

Please supply an up-to-date TypeScript language specification. The only thing I could find was one for version 1.8 at https://github.com/microsoft/TypeScript/blob/master/doc/spec.md. I would like to parse TypeScript in a language other than JavaScript or TypeScript, preferably with ANTLR4, so I guess some formal grammar would do. I would think you have that somewhere in this project, but I cannot find it.

@MartinJohns
Copy link
Contributor

Duplicate of #15711.

@sandersn sandersn added the Duplicate An existing issue was already created label Sep 6, 2019
@fljmayer
Copy link
Author

fljmayer commented Sep 6, 2019

It's not exactly a duplicate. I just need some formal grammar to parse TypeScript. How would you parse TypeScript without that?

@MartinJohns
Copy link
Contributor

There is no formal grammar available. You can look at the source of the compiler on how to parse TypeScript, or you can write a grammar yourself.

@fljmayer
Copy link
Author

fljmayer commented Sep 6, 2019

Could you please recommend an entry point where I can get an AST for a file or just a string containing TypeScript? Assuming there is some form of AST of course.

@weswigham
Copy link
Member

ts.createSourceFile creates an AST.

@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot
Copy link
Collaborator

This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@fljmayer
Copy link
Author

Thanks. Now I am trying to determine the type of a PropertyDeclaration in the SourceFile that only has an inititializer, no type. When I call TypeChecker.getContextualType() for the initializer expression it always returns undefined. Am I missing something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants