This repository was archived by the owner on Jan 19, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 75
How to hande declare var stataments? #185
Labels
Comments
I have PR #163 that does something similar for declared classes. I think we should use a new node type. Something like TSAmbientVariable or TSVariableDeclaration. I don't really think we should copy the flow node types since typescript has its own unique features as you mentioned. |
Pajn
added a commit
to Pajn/typescript-eslint-parser
that referenced
this issue
Mar 19, 2017
Pajn
added a commit
to Pajn/typescript-eslint-parser
that referenced
this issue
Apr 3, 2017
@soda0289 Do we have a solution for this issue? Turns out the way we look at the source in prettier has some ugly side-effects. prettier/prettier#2604 |
We can look at addressing the AST for this in the new parser project: https://github.com/JamesHenry/typescript-estree |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Another thing I run in to when playing with prettier/prettier/issues/13 is
declare var
statements.Currently prettier transforms
to
(the declare modifier is gone)
If we want to follow the Flow AST typescript-eslint-parser must parse it into an
DeclareVariable
node.The
DeclareVariable
node is basically aVariableDeclarator
directly (which otherwise are elements in thedeclarations
array ofVariableDeclaration
).The TS AST does instead set the
DeclareKeyword
as a modifier on theSyntaxKind.VariableStatement
node (which usually becomes aVariableDeclaration
).A quick fix is this patch
however it breaks quite soon as TypeScript seem to allow multiple declarations in the same statement like so:
So it seems like a new node type or a custom property on the variable declaration might be needed.
This probably isn't the highest priority issue for typescript support in prettier, I just happened to get one of those in my initial pull of test files. But I still wanted to submit an issue so it isn't forgotten :)
The text was updated successfully, but these errors were encountered: