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

ts5中的新版decorators无法正常运行 #11103

Closed
WisestCoder opened this issue May 6, 2023 · 4 comments · Fixed by #11115
Closed

ts5中的新版decorators无法正常运行 #11103

WisestCoder opened this issue May 6, 2023 · 4 comments · Fixed by #11115

Comments

@WisestCoder
Copy link

umi新版已经支持ts5,ts5已经支持新版的decorators,但umi内置的babel插件还是老版的decorators。
手动在.umirc中引入新版的decorators插件

extraBabelPlugins: [
    ["@babel/plugin-proposal-decorators", { "version": "2023-01" }]
  ]

会报错,报错如下:

Module build failed (from ./node_modules/@umijs/bundler-webpack/compiled/babel-loader/index.js):
Error: Cannot use the decorators and decorators-legacy plugin together
@github-actions
Copy link

github-actions bot commented May 6, 2023

由于缺乏足够的信息,我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 6, 2023
@fz6m
Copy link
Member

fz6m commented May 6, 2023

目前没有计划支持官方标配 deco ,和 TS 的 deco 相比十分逊色,不推荐使用。

如有 deco 需求,可以使用 TS 标准的 deco 。

@WisestCoder
Copy link
Author

WisestCoder commented May 8, 2023

@fz6m 我使用的就是TS5.0新出的标准的deco,具体可以看这里:https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#decorators

源码 https://github.com/umijs/umi/blob/master/packages/babel-preset-umi/src/index.ts#L82
这里装饰器的babel插件配置是还是legacy版本

umi配置现在貌似也无法修改umi内置的babelOpts

@fz6m
Copy link
Member

fz6m commented May 8, 2023

这里的就是 ecma 标准的官配 deco ,是原 TS deco 的超级阉割版本,功能上没有优势,目前没有计划支持。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants