Marak / colors.js

get colors in your node.js console
https://github.com/Marak/colors.js
Other
5.17k stars 446 forks source link

Allow to enable/disable colors when colors.js is imported as an ES6 module #221

Closed bcaudan closed 6 years ago

bcaudan commented 6 years ago

I am using typescript and this code:

import * as colors from "colors"; 

colors.enabled = true;

give me this error:

error TS2540: Cannot assign to 'enabled' because it is a constant or a read-only property    

As explained in https://github.com/Microsoft/TypeScript/issues/6751, there are workarounds but the right way could be to expose methods to enable/disable colors.

If it sounds relevant to you, I would be glad to help.

DABH commented 6 years ago

Interesting! This is definitely a bug. We should avoid workarounds (sounds like they're all basically about ignoring ES6 style), so your proposed solution of adding a setEnabled(bool) sounds good to me. If you add it to the JS lib and the TS definitions, I'd happily accept a PR. Thank you!

DABH commented 6 years ago

This will be included in the next release. Thanks again!