后续属性声明必须具有相同的类型。属性字符串应为type()=>串

时间:2018-02-06 09:59:56

标签: typescript colors

在@ types / colors模块中,index.d.ts文件包含属性bold:string。这是抛出这个错误:

node_modules/@types/colors/index.d.ts(118,9): error TS2717: Subsequent property declarations must have the same type.  Property 'bold' must be of type '() => string', but here has type 'string'.

我试过,用

替换属性
bold: () => string

这实际上解决了这个问题。但是,此编辑发生在节点模块上。根据最新发布的颜色模块,它不存在?

有什么建议吗?

2 个答案:

答案 0 :(得分:3)

bold中添加了{p> es2015,并在lib.es2015.d.ts中定义,具体取决于您的应用程序使用的内容,您可以使用较旧的lib.es5.d.ts并可能添加一些es2015个库虽然不是全部都可以与es5一起使用。这是我测试的配置,它可以工作:

"compilerOptions": {
    "target": "es2015",
    "lib": [
        "es5",
        "es2015.iterable",
        "es2015.collection",
        "es2015.symbol.wellknown",
        "es2015.promise",
        "es2015.symbol",
        "es2015.generator",
        "dom.iterable",
        "dom",
        "scripthost"
    ],
}

答案 1 :(得分:-2)

相关问题