Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bold causing problems #168

Closed
nevster opened this issue Sep 5, 2016 · 11 comments
Closed

bold causing problems #168

nevster opened this issue Sep 5, 2016 · 11 comments

Comments

@nevster
Copy link

nevster commented Sep 5, 2016

Hi Marak,

There's currently a problem as referenced here:
#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

@Marak
Copy link
Owner

Marak commented Sep 5, 2016

Will accept pull request

@DABH
Copy link
Contributor

DABH commented Feb 12, 2018

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.

@alexandrebours
Copy link

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

@DABH
Copy link
Contributor

DABH commented Feb 15, 2018

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

@DABH
Copy link
Contributor

DABH commented Feb 22, 2018

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

@DABH
Copy link
Contributor

DABH commented Feb 22, 2018

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

@DABH
Copy link
Contributor

DABH commented Feb 22, 2018

(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!)

@DABH
Copy link
Contributor

DABH commented Mar 7, 2018

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

@Dante-101
Copy link

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

https://github.com/Dante-101/colors-ts-def-mwe

@DABH
Copy link
Contributor

DABH commented Mar 10, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants