Why wont typescript recognize the colors npm package?

Viewed 718

Really easy question, in node js I can do something like this:

import 'colors';
console.log('Im blue (ba da bo de ba bo di)'.cyan.bold.underline);

Which will print blue colored text to the console. However, this same code will not run in typescript, because of the error:

Error: Property 'cyan' does not exist on type 'Im blue...'

I installed the colors types package, installed the node types package, and tried "", '', and ``, none of which worked.

I know I can just force typescript to ignore the error, but what is the 'correct' way to fix this issue?

0 Answers
Related