TypeScript 错误提示属性不存在,但实际上它应该存在,可能是由以下原因导致的:
interface MyObject {
myProperty: string;
}
const obj = {} as MyObject;
class MyClass implements MyObject {
myProperty: string = '';
}
const obj: MyObject = {
myProperty: 'Hello, world!',
};
interface MyObject {
myProperty: string;
}
const obj = {
myProperty: 'Hello, world!',
} as MyObject;
领取专属 10元无门槛券
手把手带您无忧上云