【发布时间】:2020-09-18 09:23:01
【问题描述】:
我有这两个简单的文件,但每次我尝试运行 testClass.ts 时都会收到此错误:
PS C:\Deno\pancakes> deno run testClass.ts
Compile file:///C:/Deno/pancakes/testClass.ts
error: TS1219 [ERROR]: Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option in your 'tsconfig' or 'jsconfig' to remove this warning.
name: string;
~~~~
at file:///C:/Deno/pancakes/testClass.ts:5:5
testClass.ts
import { notNull } from "./mod.ts";
class Person {
@notNull
name: string;
constructor(name: string) {
this.name = name;
}
}
let newPerson = new Person("");
mod.ts
export function notNull(target: any, propertyKey: string) {
console.log(target, propertyKey);
}
我已经在 VSCode 中启用了 experimentalDecorators 选项,创建了 tsconfig.json 和所有内容,但仍然无法运行程序。我在VSCode中没有显示错误但无法运行。
【问题讨论】:
标签: typescript decorator deno typescript-decorator