方法调用:
this.onChangeScoreGradeType(this.gradingKeyForm.get("scoreGradeType").value.key);
方法定义:
onChangeScoreGradeType(scoreGradeType: KeyValue<string,string>)
{
}
this.gradingKeyForm.get("scoreGradeType").value
是类型KeyValue<string,string>
为什么会出现没有编译错误,那
this.gradingKeyForm.get("scoreGradeType").value.key
哪个字符串不适合KeyValue<string,string>
实例?
我必须在我的 TypeScript 设置中进行哪些更改?
export default class KeyValue<TKey,TValue>
{
constructor(public key: TKey,public value: TValue)
{
}
}
tsconfig.json
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"
]
}
}