【发布时间】:2017-09-21 07:03:16
【问题描述】:
我对 React 和 TypeScript 都是新手,所以我可能遗漏了一些明显的东西。我正在尝试执行以下操作:
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?因为你的第一个代码 sn-p 应该没有问题。
标签: reactjs typescript