Marak / colors.js

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

Property 'bold' does not exist on type '(str: string) => string'.ts(2339) #254

Open marcospgp opened 5 years ago

marcospgp commented 5 years ago

Trying to use colors.red.bold (safe method) and I get the error in title, using typescript.

mlucic commented 5 years ago

For anyone else coming across this issue, a simple way to get around this is the following: colors.bold(colors.red('text'))

ohabash commented 4 years ago

How can i achieve this syntax in TS?

console.log('Error Msg'.red)

kaanguru commented 4 years ago

typescript says:

Cannot find name 'colors'.

FossPrime commented 3 years ago

Sounds like the types are wrong and this should return a Color, which is a class that inherits String Look at this, thing: console.log(colors.bgGreen(colors.white(colors.bold(msg)))

It looks like safe does not export a definition for property style use of the red, only a function red.

The trick is to handle unknown uses of red as one, and only export the readonly property https://github.com/chalk/chalk/blob/main/index.d.ts#L153