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.0 #8646

Closed
sosukesuzuki opened this issue Jun 26, 2020 · 12 comments · Fixed by #8982
Closed

Support TypeScript 4.0 #8646

sosukesuzuki opened this issue Jun 26, 2020 · 12 comments · Fixed by #8982
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency

Comments

@sosukesuzuki
Copy link
Member

sosukesuzuki commented Jun 26, 2020

TypeScript 4.0 beta has been released!

https://devblogs.microsoft.com/typescript/announcing-typescript-4-0-beta/

We need to support new syntaxes:

note: We should wait typescript-eslint/typescript-eslint#2260 for default TS parser and babel/babel#11760 for babel-ts parser.

@sosukesuzuki sosukesuzuki added scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) labels Jun 26, 2020
@sosukesuzuki sosukesuzuki pinned this issue Jun 26, 2020
@orta
Copy link
Contributor

orta commented Jun 26, 2020

Also a catch clause can legally have a type now (only : any and : unknown are allowed) - today Prettier drops it entirely

Playground

@bradennapier
Copy link

bradennapier commented Jun 27, 2020

Yep and it may be useful to drop if its anything other than any or unknown but may be getting more into a linting-like situation there which @typescript-eslint should instead implement.

Def looking forawrd to this for the variadic tuples once prettier supports it :-P

another one to look out for that isn't obvious at first:

type ReduceNextElement<
  T extends readonly unknown[]
  // eslint-disable-next-line prettier/prettier
> = T extends readonly [infer V, ...infer R] ? [V, R] : never

Prettier will currently change this to

type ReduceNextElement<T extends readonly unknown[]> = T extends readonly [
  infer V,
  ...(infer R)
]
  ? [V, R]
  : never;

which produces a ts error:

image

Where we expect the following:

type Check = ReduceNextElement<[1, 2, 3]>; // [1, [2, 3]]

@fisker
Copy link
Member

fisker commented Jul 21, 2020

Type annotations on catch clauses #8805

@wclr
Copy link

wclr commented Jul 29, 2020

Labeled tuples not supported.

@fisker
Copy link
Member

fisker commented Aug 3, 2020

Labeled tuples for babel-ts #8885

@harrysolovay

This comment has been minimized.

@liamcarter111
Copy link

Since Typescript official 4.0.2 was released to the masses yesterday, any update on when #8982 will be released?

@sosukesuzuki
Copy link
Member Author

We are working for release 2.1(#8882), please wait.

@sosukesuzuki sosukesuzuki unpinned this issue Aug 24, 2020
@papb
Copy link

papb commented Aug 25, 2020

Hello @sosukesuzuki, I am still experiencing the issue reported by @bradennapier above, in which ...infer T is incorrectly replaced with ...(infer T). I am using Prettier 2.1.0. I will work around this with // prettier-ignore for now.

@bradennapier
Copy link

Figured it'd get missed ;) subtle difference but completely breaks inference.

@fisker
Copy link
Member

fisker commented Aug 25, 2020

Can you raise another issue? I think we missed that

@papb
Copy link

papb commented Aug 25, 2020

@fisker Done! #9041

@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 Nov 24, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:typescript Issues affecting TypeScript-specific constructs (not general JS issues) locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants