Marak / colors.js

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

shorter syntax not working in TypeScript #268

Open ohabash opened 4 years ago

ohabash commented 4 years ago

How can i achieve this syntax in my TS project

console.log('hello'.red) <== instead of "hello", undefined is printed

wrule commented 4 years ago

me too

wrule commented 4 years ago

maybe you can try import 'colors' dont use import colors from 'colors' its solved my problem

mikemklee commented 4 years ago

I had the same problem and verifed @wrule 's solution works.

kerberjg commented 3 years ago

Doesn't work for me when targetting module 'ESNext' in TypeScript, I've tried both import 'colors' and require('colors'), but to no avail

kerberjg commented 3 years ago

UPDATE: fixed by setting moduleResolution to "node" in tsconfig.json

enwi commented 2 years ago

I had the same issue, but the following did the trick:

import * as Color from 'colors';

// below line fixes color print
Color.red;

console.log('Oh my heavens! '.rainbow);