prettier: Missing TypeScript Nodes (2)
See https://github.com/prettier/prettier/issues/1480#issuecomment-299230108 for up to date info
There are still some nodes missing, but we’re getting there 😃
Missing printer implementation:
- “TSAsyncKeyword” (#1483)
- “TSDecorator” (#1488)
- “TSExportKeyword” (#1483)
- “TSNamespaceFunctionDeclaration” (#1483)
- “TSProtectedKeyword” (#1483)
- “TSPublicKeyword” (#1483)
- “TSHeritageClause” (#1483)
- "TSExpressionWithTypeArguments (#1483)
Missing in typescript-ast-nodes.js
:
- “TSParameterProperty”
- “TSTypeParameter”
There are also some nodes printed incorrectly, probably because some optional keywords aren’t printed which should be easy to fix. And there are errors where we’re trying to access properties on undefined, those are probably because TypeScript types are missing in typescript-ast-nodes.js
or because we expect optional stuff to just be there.
The raw output of running prettier of the TypeScript test suite can be found here (careful, it’s big).
If anyone wants to help with this drop a line here, so we don’t duplicate the effort.
/cc @azz
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 32
- Comments: 52 (31 by maintainers)
Commits related to this issue
- feat(typescript): #1480: implement *Keyword, namespace function and class heritage — committed to azz/prettier by azz 7 years ago
- feat(typescript): #1480: implement *Keyword, namespace function and class heritage — committed to azz/prettier by azz 7 years ago
- feat(typescript): #1480: implement *Keyword, namespace function and class heritage — committed to azz/prettier by azz 7 years ago
- Implement TypeScript keywords, namespace functions and class heritage (#1483) * feat(typescript): #1480: implement *Keyword, namespace function and class heritage * feat(typescript): add type para... — committed to prettier/prettier by azz 7 years ago
- Do not throw on an empty file with a ; Fixes "TypeError: Cannot read property 'replace' of undefined" This was discovered by #1480 and also affects non-typescript — committed to vjeux/prettier by vjeux 7 years ago
- Do not throw on an empty file with a ; (#1503) Fixes "TypeError: Cannot read property 'replace' of undefined" This was discovered by #1480 and also affects non-typescript — committed to prettier/prettier by vjeux 7 years ago
As I’m reading through answers from my tweet ( https://twitter.com/Vjeux/status/859444410869727232 ), a lot of people are eagerly waiting for TypeScript support to push it through their codebase at work. You are working on something really impactful!
Guys, I just wanted to let you know that I highly appreciate that you’re building support for TypeScript in prettier! Looking forward to start using it across all my projects 👍
I started integrating
eslint-parser-typescript
’s master branch and fixing what it breaks, just so you know.this is something im interested too. I can work on few as well
If you are interested, how master looks on inferno, pretty damn close 😃 https://github.com/infernojs/inferno/pull/1069
Here is a list of unique errors that still happen:
And here is the whole output (careful big file).
So we’re exceptionally close to not crashing on any valid TypeScript 😄.
Whoever wants to try to fix any error, drop a line. I’ll start with
TSConstKeyword
. Happy hacking!After #1483, down to
So, this divided the number of broken tests by 2!! Keep it up 😃
I should be able to help out with some on Thursday too, as I have the day off 😄
@azz, none of those are syntactically valid JS, so I wouldn’t worry too much about it.
Just FYI to all you wonderful people working on TS support in prettier, we have merged in some major PRs to
typescript-eslint-parser
(which powers the prettier TS parser) today.Of particular note:
The
typescript-eslint-parser
codebase itself has been refactored (https://github.com/eslint/typescript-eslint-parser/pull/261), and whilst this does not change any ASTs, it will affect any of you that have forks of the project.@Pajn’s PR to normalize type parameters (https://github.com/eslint/typescript-eslint-parser/pull/196), this is a breaking change for relevant ASTs and so will affect (hopefully greatly improve) relevant prettier work.
There is a chance @Pajn has some relevant prettier WIP, but I know that he has been busy moving cities, so not sure of the status.
I also added printer for TSHeritageClause and TSExpressionWithTypeArguments.
I’m taking a look at TSExportKeyword at the moment.All keywords are done. Looking at TSNamespaceFunctionDeclaration.
TSDecorator is still up for grabs.
TODO:
questionToken
is not printed:readonlyToken
is not printed in mapped types:Do not put
[]
aroundLiteral
nodes on LHS in interface.Print parens around arrow functions in this case:
Extraneous newline on second print. Also occurs with functions:
Unstable re-print:
instanceof
fix merged, thanks for that! Literally no idea why I didn’t PR that working branch before 😄Worth noting that typescript-eslint-parser had a breaking change recently, which will presumably need fixing here.
Thanks, @despairblue!
We are trying to get in as many necessary breaking changes as possible before we declare prettier TS support “stable”.
Another tiny one (in terms of the changes required in prettier) coming: https://github.com/eslint/typescript-eslint-parser/pull/219
We will need to change the parser config to use
comment: true
, ratherattachComment: true
as it currently is.Just FYI I am waiting to hear back from @Pajn on https://github.com/eslint/typescript-eslint-parser/pull/196
I am assuming that is currently blocking a related prettier PR, although one is not mentioned specifically
I just opened https://github.com/eslint/typescript-eslint-parser/issues/250 on typescript-eslint-parser for decorators being inconsistently outputted and #1509 as a workaround on prettier, but I’d rather not ship it and get it fixed upstream.