use*_*909 5 typescript tsconfig next.js typescript-decorator
我将 typeorm 与 next.js 和 typescript 一起使用,我的 tsconfig.json 是:
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext",
"es5",
"es6"
],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"jsx": "preserve"
},
include: ...
}
Run Code Online (Sandbox Code Playgroud)
我设置experimentalDecorator 为true。我的打字稿是 3.9.7,我的打字稿是 0.2.25。编译错误是:
error - ./db/entity/User.ts:7:1
Syntax error: Support for the experimental syntax 'decorators-legacy' isn't currently enabled:
5 |
6 |
> 7 | @Entity()
| ^
8 | export class User {
9 |
10 | @PrimaryGeneratedColumn()
Run Code Online (Sandbox Code Playgroud)
我已经启用了emitDecoratorMetadata,Hoe 为tsconfig.json 启用decorators-legacy
我的一个同事刚刚遇到了同样的问题:这是 Babel 抛出的错误,它无法处理类装饰器。事实上,即使您不在代码中使用 Babel,Next.JS 也会在前端使用。
确保./db/entity/User.ts
您的前端代码中没有导入或任何其他 TypeORM 类。
归档时间: |
|
查看次数: |
1050 次 |
最近记录: |