当我在下面定义一个简称Class
时,我认为没有比此更简单的Class
class Greeter {
greeting: string;
constructor(message: string) {
this.greeting = message;
}
}
let greeter = new Greeter("world");
但是,编译此代码时,终端将调用错误错误TS2339: Property 'greeting' does not exist on type 'Greeter'.
我不知道这个错误...
这是我的tsconfig.json
{
"compilerOptions": {
"strictNullChecks": false,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"jsx": "preserve",
"noUnusedParameters": true,
"noUnusedLocals": true,
"target": "es6",
"lib": [
"dom",
"es7"
]
},
"exclude": [
"node_modules",
"lib",
"es"
]
}