How to use chalk with Typescript

This is the most easy way to solve the chalk usage in TS.

After dealing with this issue for a couple of hours, I found the most accurate way to solve the usage of Chalk in Typescript.

Some context: After the version 5 of Chalk it relies in more dependencies and configurations than before. So, to solve this I found this version:

Step 1: Install the latest 4.x version.

npm install chalk@4.1.2

Step 2: The Chalk dependency can be used with require or import syntax

// Using import in JS or TS
const chalk = require('chalk');
console.log('Hello world In Green!'));
// Using import in TS
import * as chalk from "chalk";
console.log("Hello world in Red!"));
// Using deconstruction import in TS
import { blue } from "chalk";
console.log(blue("Hello world in blue!"));

And that's it, hope you enjoyed.

Happy hacking!