Closed nevster closed 6 years ago
Will accept pull request
Can you confirm whether or not this is still an issue with the typings? Otherwise I will investigate at some point, I'm interested in full TS compliance and moving the typings out of DT to this repo.
There is still an issue on my side: 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'.
Yeah, I’ve since read more — the issue is that ES6 has “bold()” as a String prototype — however, that is deprecated. So at some point these typings should be correct again :) but in the meantime we can see what an elegant fix is...
I couldn't seem to repro as I was messing around trying to solve this. Can someone (@alexandrebours ?) provide a MWE that triggers the TS2717, so I can investigate as well?
Moreover, very open to any ideas/workarounds...
Is it sufficient to ignore the error?? http://www.typescriptlang.org/play/#src=declare%20module%20%27foo%27%20%7B%0A%09global%20%7B%0A%09%09interface%20String%20%7B%0A%09%09%09%2F%2F%20%40ts-ignore%0A%09%09%09bold%3A%20string%3B%0A%09%09%7D%0A%09%7D%0A%7D%3B%0A%0Alet%20x%3Aany%20%3D%20%27bob%27.bold%3B That seems to avoid errors (without the ignore I can indeed repro now, woo hoo).
But even though this silences the error, does colors
' bold work from Typescript now? If so, let's make this the official solution... lmk...
(Actually, I only have this silly browser example, without importing colors
... if someone can provide a full .ts
file and some tsc
command that reproduces this, I'd be grateful!)
MWE provided thanks to @Dante-101 ... I’ll try applying my tentative fix to it soon-ish unless someone beats me to it. Note we should test against master branch of colors which now has the built-in typings and al the other 1.2.0 fixes
@SlurpTheo We need to make it work with targets newer than ES2015. A lot of us use esnext
with Babel to write TS in latest syntax. It will be great if we can make this MWE work.
So seems like my ignore trick works lol. Thanks again for the MWE. I'm going to push my "fix," and then mark this closed. But, if anyone ever has a more elegant fix, or if bold is finally removed from ES, someone please re-open or make a new issue.
Hi Marak,
There's currently a problem as referenced here: https://github.com/Marak/colors.js/issues/110
When using colors in TypeScript, we get the following error: typings/globals/colors/index.d.ts(109,5): error TS2300: Duplicate identifier 'bold'
Is it possible for you to implement a workaround or at least update the typings here?: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/colors
Thanks