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

Doesn't support TypeScript 4's labeled tuple syntax #9208

Closed
cakoose opened this issue Sep 15, 2020 · 3 comments
Closed

Doesn't support TypeScript 4's labeled tuple syntax #9208

cakoose opened this issue Sep 15, 2020 · 3 comments
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.

Comments

@cakoose
Copy link

cakoose commented Sep 15, 2020

Prettier v2.1.1 reports a syntax error in the following code.

type X = [a: string, b: string];  // SyntaxError: Unexpected token, expected "," (1:12)

Prettier playground: link

TypeScript playground: link

TypeScript added this syntax in v4: "labeled tuple elements" in the release notes

There was an earlier bug and apparently also a fix: #8646 (comment). Maybe I'm missing something?

@cakoose
Copy link
Author

cakoose commented Sep 16, 2020

Oh hmm, looks like the original fix (#8885) had a caveat:

Current typescript-estree cannot parse labeled tuple types. So we should put this in /tests/misc/typescript-babel-only for now.

That was on Aug 3. A week later @typescript-eslint/typescript-estree 3.9 was released and claims to support labeled tuple types: ChangeLog v3.9. And Prettier's current @typescript-eslint/typescript-estree dependency is v3.10.1.

@sosukesuzuki
Copy link
Member

You seem to be using a babel parser. please use the typescript parser or the babel-ts parser.

Prettier 2.1.1
Playground link

--parser typescript

Input:

type X = [a: string, b: string];

Output:

type X = [a: string, b: string];

@cakoose
Copy link
Author

cakoose commented Sep 16, 2020

Thanks!

The default parser seems to accept many TypeScript constructs, which I guess confused me a bit...

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Dec 16, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

2 participants