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

Support TypeScript 4.1 via typescript-estree #9636

Merged
merged 44 commits into from Nov 18, 2020

Conversation

sosukesuzuki
Copy link
Member

@sosukesuzuki sosukesuzuki commented Nov 10, 2020

Partial of #9234

This PR tries the approach @thorn0 suggested (27e7b46)

  • I’ve added tests to confirm my change works.
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/pr-XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

Comment on lines 3 to +5
const {
concat,
join,
hardline,
line,
softline,
group,
indent,
ifBreak,
} = require("../document").builders;
builders: { concat, join, hardline, line, softline, group, indent, ifBreak },
} = require("../document");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why, but this change removes the TypeScript typecheck error. Why...?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe #9207

@sosukesuzuki
Copy link
Member Author

All prod tests are failed. I'm looking into that.

@fisker
Copy link
Sponsor Member

fisker commented Nov 11, 2020

Seems we can access decorators via services

require("@typescript-eslint/typescript-estree").parseAndGenerateServices('@foo\nfunction bar(){}').services.program.getSourceFile().statements[0]

@fisker
Copy link
Sponsor Member

fisker commented Nov 12, 2020

I'm going to take a shot

@fisker
Copy link
Sponsor Member

fisker commented Nov 17, 2020

@typescript-eslint/typescript-estree@4.8.0 released, working on it.

@fisker
Copy link
Sponsor Member

fisker commented Nov 17, 2020

@bradzacher Did I do something wrong? There is no info in esTreeNodeToTSNodeMap

> const {ast, esTreeNodeToTSNodeMap} = require("@typescript-eslint/typescript-estree").parseWithNodeMaps('@foo()\nfunction bar(){}')
undefined
> esTreeNodeToTSNodeMap.get(ast.body[0])
undefined
> const {ast, services:{esTreeNodeToTSNodeMap}} = require("@typescript-eslint/typescript-estree").parseAndGenerateServices('@foo()\nfunction bar(){}')
undefined
> esTreeNodeToTSNodeMap.get(ast.body[0])
<ref *1> NodeObject {
  pos: 0,
  end: 23,
  flags: 0,
  modifierFlagsCache: 0,
  transformFlags: 1050625,
  parent: <ref *2> SourceFileObject
//...

@bradzacher
Copy link

FFS I'm a stooge.
https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/typescript-estree/src/parser.ts#L383

The false here means "don't calculate maps".
I can't believe I didn't think about that!
My test just asserted the maps existed, not that they contained anything.
🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦🤦

I'll have a fix released ASAP.

@fisker

This comment has been minimized.

@bradzacher
Copy link

typescript-eslint/typescript-eslint#2773 is merged, but I can't do an NPM release right now as azure pipelines have an outage....
Yeah we need to move it to GH actions. Will ping back when it's released.

For now you can test against
https://www.npmjs.com/package/@typescript-eslint/typescript-estree/v/4.8.1-alpha.1
Which releases via GH actions.

@fisker fisker requested a review from thorn0 November 17, 2020 06:41
@sosukesuzuki
Copy link
Member Author

Can we merge this as is? or should wait 4.8.1?

@fisker
Copy link
Sponsor Member

fisker commented Nov 17, 2020

I don't think we need wait for @typescript-eslint/typescript-estree , but do we need wait for typescript release stable version?

@sosukesuzuki
Copy link
Member Author

TypeScript 4.1 will seem be released soon according to microsoft/TypeScript#40124. Let's wait.

@bradzacher
Copy link

4.8.1 is live with the fix :)

@fisker
Copy link
Sponsor Member

fisker commented Nov 18, 2020

Hey all, we're going to retarget to Thursday (11/19) just to ensure that everything is working as optimally as possible and documented.

microsoft/TypeScript#40124 (comment)

@sosukesuzuki
Copy link
Member Author

I see. let's merge this PR for now. I'll do the other work required for the release.

When TypeScript 4.1 is released, I'll create a PR just to update it.

@sosukesuzuki sosukesuzuki merged commit 4cc1492 into prettier:master Nov 18, 2020
@sosukesuzuki sosukesuzuki deleted the update-ts-estree branch November 18, 2020 02:00
@wdoug wdoug mentioned this pull request Nov 20, 2020
@sosukesuzuki sosukesuzuki mentioned this pull request Nov 20, 2020
1 task
@fisker fisker mentioned this pull request Dec 31, 2020
4 tasks
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants