我是React和TypeScript的新手,所以可能会有一些显而易见的错误。我试图做到以下几点:React TypeScript属性'assign'在类型'Object constructor'上不存在
const props = Object.assign({}, this.props, {
loaded: this.state.loaded
});
我在.tsx
文件中得到这个错误:Property 'assign' does not exist on type 'Object constructor'.
发现this thread和尝试:
const props = (<any>Object).assign({}, this.props, {
loaded: this.state.loaded
});
给了我这个错误:Property 'any' does not exist on type 'JXS.IntrinsicElements'.
我也试过这个返回Unexpected modifier
申报。
declare interface ObjectConstructor {
assign(target: any, ...sources: any[]): any;
}
我错过了什么?
这有点奇怪。你可以提供更多的背景吗?例如。你使用它的组件,也可能是你的'tsconfig'?因为第一个代码片段不应该有问题。 –