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

TypeScript 5.0 features #15374

Closed
2 tasks done
nicolo-ribaudo opened this issue Jan 27, 2023 · 9 comments
Closed
2 tasks done

TypeScript 5.0 features #15374

nicolo-ribaudo opened this issue Jan 27, 2023 · 9 comments
Labels
area: typescript i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Jan 27, 2023

@JLHwung
Copy link
Contributor

JLHwung commented Jan 27, 2023

Although TS 5.0 also supports ES decorators, we will not add decorators transform to the preset-typescript like we did for other stage 3 features. Use the following config if you want to try ES decorators and TS 5.0 features:

{
  "presets": ["@babel/preset-typescript"],
  "plugins": [["@babel/plugin-proposal-decorators", { "version": "2022-03" }]]
}

@liuxingbaoyu
Copy link
Member

liuxingbaoyu commented Jan 28, 2023

babel
ts

There is a possible output optimization(const enum) here, but it's not urgent, we can implement it when we have time.

microsoft/TypeScript#50528

Fixed in #15379

@JLHwung
Copy link
Contributor

JLHwung commented Jan 28, 2023

I remember I needed to use this somewhere in our code, but I cannot find where anymore

@nicolo-ribaudo Did you mean

export * from "./ast-types/generated";

?

@nicolo-ribaudo
Copy link
Member Author

Yes!

@nicolo-ribaudo
Copy link
Member Author

The TS decorators syntax is slightly different from the JS decorators syntax: tc39/proposal-decorators#69

However, since there is active discussion about it, I prefer to wait until TS 5.0 stable before implementing it.

@wycats
Copy link

wycats commented Jan 30, 2023

Although TS 5.0 also supports ES decorators, we will not add decorators transform to the preset-typescript like we did for other stage 3 features. Use the following config if you want to try ES decorators and TS 5.0 features:

{
  "presets": ["@babel/preset-typescript"],
  "plugins": [["@babel/plugin-proposal-decorators", { "version": "2022-03" }]]
}

What's the rationale?

@JLHwung
Copy link
Contributor

JLHwung commented Jan 30, 2023

preset-typescript only transforms TS-only language features. Decorators, as an ES language feature, will be included in preset-env eventually when it reaches stage 4.

@nicolo-ribaudo
Copy link
Member Author

For example, @babel/preset-typescript doesn't transform class fields even if TSC does.

@nicolo-ribaudo
Copy link
Member Author

Released in 7.21.0

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: typescript i: enhancement outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

4 participants