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
typecheck updates & fixes in src/language-js #8759
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of TODO, can we remove them and adding types late in other PRs?
I just merged changes from master & replaced TODO with |
8c024a7
to
cf142e4
Compare
I just rebased this proposal with a hopefully cleaner commit history, with some updates:
At this point there are 2
Other
|
/cc @prettier/core |
src/language-js/printer-estree.js
Outdated
@@ -672,8 +683,9 @@ function printPathNoParens(path, options, print, args) { | |||
options.locEnd | |||
); | |||
return ( | |||
nextCharacter && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nextCharacter && | |
nextCharacter !== false && |
I wish we had a good way to test this kind of case.
Saw this #8759 (comment)? |
OK so Prettier basically uses its own "estree" format which can handle estree or estree-like AST structure that comes out of the Babel, Flow, or typescript-estree parser modules. I am wondering about a couple things, though:
I will probably take my rest pretty soon. Unfortunately I have some other priorities that I had put off for a while and may not be able to contribute much more over the next 1-2 weeks or so. I hope we can finish this PR without too much more work now and consider improving the type check in future PRs. |
Latest estree.d.ts updates in 5414a62 look good to me, thanks. |
// MUST REMOVE to avoid errors with TypeScript 4.0.0: | ||
import * as ts from "typescript"; | ||
declare module "typescript" { | ||
type NamedTupleMember = Node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work even with TypeScript 4.x:
type NamedTupleMember = Node; | |
export interface NamedTupleMember extends Node {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ExE-Boss. I would actually favor keeping this workaround as-is, errors can remind us to remove it with the TypeScript 4 update. Nice idea, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to remove this entire workaround if typescript-eslint/typescript-eslint#2405 is merged and released. I hope this will be possible.
… calls", to avoid a merge conflict from master This reverts commit d307f74.
…nguage-js-jsdoc-types
Good job |
Teamwork yeah! |
updated:
src/language-js/types/estree.d.ts
to facilitate clean parameter types insrc/language-js/utils.js
add a single@ts-ignore
comment, to work around a type issue remaining insrc/language-js/utils.js
src/language-js
&src/common/parser-create-error.js
from exclude list intsconfig.json
src/language-js/print/ternary.js
, based on the changes I had originally proposed in PR refactor typedefs in src/language-js/print/ternary.js #8745src/main/comments.js
, as described below(there used to be many more
@ts-ignore
comments, which are now resolved)P.S. I suspect some of the minor code updates can make the code a little more robust. It would be interesting to see if we can think of any test cases to prove this or not.
✨Try the playground for this PR✨