3

在 chalk 2.0 中,可以使用标记字符串

const chalk = require('chalk');
console.log(chalk`{bold some} text`);

如何修改 chalk 的类型定义以使 TypeScript 满意?目前,我得到:

错误 TS2349:无法调用其类型缺少调用签名的表达式。类型“typeof Chalk”没有兼容的调用签名。

4

1 回答 1

0

With Typescript, you should be using the import syntax vs require, and the error will go away.

import chalk from 'chalk';

Note that at the time you posted your question, there was also a template issue, but it has been fixed since.

于 2021-03-20T11:22:55.177 回答