在TSX Typescript文件中使用Polymer 1.0自定义标记



我试图在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

最新更新