Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Subsequent property declarations must have the same type. Property string should be of type () => string

In @types/colors module, index.d.ts file contails a property bold: string. this is throwing this error:

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'.

I tried, replacing the property with

bold: () => string

This actually fixed the issue. However, this edit happend at node modules. As per latest release of colors module, its not there?

Any suggestions please?

like image 550
rgk Avatar asked Jan 22 '26 00:01

rgk


1 Answers

bold was added in es2015 and is defined in lib.es2015.d.ts, depending on what your application uses, you could use the older lib.es5.d.ts and maybe add back some of the es2015 libraries, although not all will work in conjunction with es5. This is the configuration I tested and it works:

"compilerOptions": {
    "target": "es2015",
    "lib": [
        "es5",
        "es2015.iterable",
        "es2015.collection",
        "es2015.symbol.wellknown",
        "es2015.promise",
        "es2015.symbol",
        "es2015.generator",
        "dom.iterable",
        "dom",
        "scripthost"
    ],
}
like image 159
Titian Cernicova-Dragomir Avatar answered Jan 24 '26 23:01

Titian Cernicova-Dragomir



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!