我试图在Typescript.tsx文件中使用Polymer自定义标记,但它导致了编译错误:
declare module JSX {
export interface IntrinsicElements {
[anything: string]: any;
}
}
let nativeTag = <br />;
let customTag = <paper-button />;
错误是:
error TS2339: Property 'paper-button' does not exist on type 'JSX.IntrinsicElements'.
有人能提示一下如何解决这个问题吗?
$ tsc --version
Version 1.8.10
我意识到这个问题有点过时了,但文档现在建议您使用declare namespace JSX
而不是module
。除此之外,我必须将整个名称空间声明封装在declare global
块中。看见https://github.com/Microsoft/TypeScript/issues/11684