doowb/ansi-colors

enabled is const and cannot be assigned.

ws93 opened this issue · 3 comments

ws93 commented

Try to disable color mode in my Typescript code.
import * as colors from "ansi-colors"; colors.enabled = false;
It pops up this error
[ts] Cannot assign to 'enabled' because it is a constant or a read-only property.

doowb commented

Is that because TypeScript is seeing this definition?

If so, could you try removing the const to see if that works? Would you also be able to do a PR to update any other types that should be able to be set?

Thanks for finding this and opening an issue.

ws93 commented

Yes, I think that's because TS checks index.d.ts file under types folder and found enabled is const.
Will submit PR after work.

For some odd reason I'm still having this problem with latest version. I can see the variable being export let ... and not const, I don't know why TS 4.9.5 doesnt like. Anyway, @ts-ignore to the rescue!