Disallow template literals on colors and modifiers (#341)
This commit is contained in:
parent
0e6fecc7f7
commit
72063704df
2 changed files with 107 additions and 90 deletions
|
|
@ -42,6 +42,10 @@ const name = 'John';
|
|||
expectType<string>(chalk`Hello {bold.red ${name}}`);
|
||||
expectType<string>(chalk`Works with numbers {bold.red ${1}}`);
|
||||
|
||||
// -- Members of the Chalk interface do not support template literals (#341) --
|
||||
expectError(chalk.bold`Hello {bold.red ${name}}`);
|
||||
expectError(chalk.bold`Works with numbers {bold.red ${1}}`);
|
||||
|
||||
// -- Color methods --
|
||||
expectType<colorReturn>(chalk.hex('#DEADED'));
|
||||
expectType<colorReturn>(chalk.keyword('orange'));
|
||||
|
|
@ -70,15 +74,15 @@ expectType<string>(chalk.inverse('foo'));
|
|||
expectType<string>(chalk.hidden('foo'));
|
||||
expectType<string>(chalk.strikethrough('foo'));
|
||||
expectType<string>(chalk.visible('foo'));
|
||||
expectType<string>(chalk.reset`foo`);
|
||||
expectType<string>(chalk.bold`foo`);
|
||||
expectType<string>(chalk.dim`foo`);
|
||||
expectType<string>(chalk.italic`foo`);
|
||||
expectType<string>(chalk.underline`foo`);
|
||||
expectType<string>(chalk.inverse`foo`);
|
||||
expectType<string>(chalk.hidden`foo`);
|
||||
expectType<string>(chalk.strikethrough`foo`);
|
||||
expectType<string>(chalk.visible`foo`);
|
||||
expectError(chalk.reset`foo`);
|
||||
expectError(chalk.bold`foo`);
|
||||
expectError(chalk.dim`foo`);
|
||||
expectError(chalk.italic`foo`);
|
||||
expectError(chalk.underline`foo`);
|
||||
expectError(chalk.inverse`foo`);
|
||||
expectError(chalk.hidden`foo`);
|
||||
expectError(chalk.strikethrough`foo`);
|
||||
expectError(chalk.visible`foo`);
|
||||
|
||||
// -- Colors --
|
||||
expectType<string>(chalk.black('foo'));
|
||||
|
|
@ -115,40 +119,40 @@ expectType<string>(chalk.bgBlueBright('foo'));
|
|||
expectType<string>(chalk.bgMagentaBright('foo'));
|
||||
expectType<string>(chalk.bgCyanBright('foo'));
|
||||
expectType<string>(chalk.bgWhiteBright('foo'));
|
||||
expectType<string>(chalk.black`foo`);
|
||||
expectType<string>(chalk.red`foo`);
|
||||
expectType<string>(chalk.green`foo`);
|
||||
expectType<string>(chalk.yellow`foo`);
|
||||
expectType<string>(chalk.blue`foo`);
|
||||
expectType<string>(chalk.magenta`foo`);
|
||||
expectType<string>(chalk.cyan`foo`);
|
||||
expectType<string>(chalk.white`foo`);
|
||||
expectType<string>(chalk.gray`foo`);
|
||||
expectType<string>(chalk.grey`foo`);
|
||||
expectType<string>(chalk.blackBright`foo`);
|
||||
expectType<string>(chalk.redBright`foo`);
|
||||
expectType<string>(chalk.greenBright`foo`);
|
||||
expectType<string>(chalk.yellowBright`foo`);
|
||||
expectType<string>(chalk.blueBright`foo`);
|
||||
expectType<string>(chalk.magentaBright`foo`);
|
||||
expectType<string>(chalk.cyanBright`foo`);
|
||||
expectType<string>(chalk.whiteBright`foo`);
|
||||
expectType<string>(chalk.bgBlack`foo`);
|
||||
expectType<string>(chalk.bgRed`foo`);
|
||||
expectType<string>(chalk.bgGreen`foo`);
|
||||
expectType<string>(chalk.bgYellow`foo`);
|
||||
expectType<string>(chalk.bgBlue`foo`);
|
||||
expectType<string>(chalk.bgMagenta`foo`);
|
||||
expectType<string>(chalk.bgCyan`foo`);
|
||||
expectType<string>(chalk.bgWhite`foo`);
|
||||
expectType<string>(chalk.bgBlackBright`foo`);
|
||||
expectType<string>(chalk.bgRedBright`foo`);
|
||||
expectType<string>(chalk.bgGreenBright`foo`);
|
||||
expectType<string>(chalk.bgYellowBright`foo`);
|
||||
expectType<string>(chalk.bgBlueBright`foo`);
|
||||
expectType<string>(chalk.bgMagentaBright`foo`);
|
||||
expectType<string>(chalk.bgCyanBright`foo`);
|
||||
expectType<string>(chalk.bgWhiteBright`foo`);
|
||||
expectError(chalk.black`foo`);
|
||||
expectError(chalk.red`foo`);
|
||||
expectError(chalk.green`foo`);
|
||||
expectError(chalk.yellow`foo`);
|
||||
expectError(chalk.blue`foo`);
|
||||
expectError(chalk.magenta`foo`);
|
||||
expectError(chalk.cyan`foo`);
|
||||
expectError(chalk.white`foo`);
|
||||
expectError(chalk.gray`foo`);
|
||||
expectError(chalk.grey`foo`);
|
||||
expectError(chalk.blackBright`foo`);
|
||||
expectError(chalk.redBright`foo`);
|
||||
expectError(chalk.greenBright`foo`);
|
||||
expectError(chalk.yellowBright`foo`);
|
||||
expectError(chalk.blueBright`foo`);
|
||||
expectError(chalk.magentaBright`foo`);
|
||||
expectError(chalk.cyanBright`foo`);
|
||||
expectError(chalk.whiteBright`foo`);
|
||||
expectError(chalk.bgBlack`foo`);
|
||||
expectError(chalk.bgRed`foo`);
|
||||
expectError(chalk.bgGreen`foo`);
|
||||
expectError(chalk.bgYellow`foo`);
|
||||
expectError(chalk.bgBlue`foo`);
|
||||
expectError(chalk.bgMagenta`foo`);
|
||||
expectError(chalk.bgCyan`foo`);
|
||||
expectError(chalk.bgWhite`foo`);
|
||||
expectError(chalk.bgBlackBright`foo`);
|
||||
expectError(chalk.bgRedBright`foo`);
|
||||
expectError(chalk.bgGreenBright`foo`);
|
||||
expectError(chalk.bgYellowBright`foo`);
|
||||
expectError(chalk.bgBlueBright`foo`);
|
||||
expectError(chalk.bgMagentaBright`foo`);
|
||||
expectError(chalk.bgCyanBright`foo`);
|
||||
expectError(chalk.bgWhiteBright`foo`);
|
||||
|
||||
// -- Complex --
|
||||
expectType<string>(chalk.red.bgGreen.underline('foo'));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue