From eac645be4f3d4dd6e8616e17c60506eea7531d86 Mon Sep 17 00:00:00 2001 From: Jonathan Van Buren Date: Sun, 23 Dec 2018 11:25:37 +0800 Subject: [PATCH 1/3] Changed tagged template literal argument type to unknown --- types/index.d.ts | 2 +- types/test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index b4e4dc5..8a7fd09 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -27,7 +27,7 @@ export interface ColorSupport { export interface Chalk { (...text: string[]): string; - (text: TemplateStringsArray, ...placeholders: string[]): string; + (text: TemplateStringsArray, ...placeholders: unknown[]): string; constructor: ChalkConstructor; enabled: boolean; level: Level; diff --git a/types/test.ts b/types/test.ts index cedb39a..45d44f4 100644 --- a/types/test.ts +++ b/types/test.ts @@ -21,6 +21,7 @@ const ctx = chalk.constructor({level: Level.TrueColor }); ctx('foo'); ctx.red('foo'); ctx`foo`; +ctx`works with numbers ${1}`; chalk.enabled = true; chalk.level = 1; From 3f9e501465ada66fd8123a7bca1f5e0bd58fdb9e Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 26 Dec 2018 13:53:47 +0800 Subject: [PATCH 2/3] Update types/index.d.ts basic, no arg form Co-Authored-By: vanbujm --- types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/index.d.ts b/types/index.d.ts index 8a7fd09..08f9b13 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -26,7 +26,7 @@ export interface ColorSupport { } export interface Chalk { - (...text: string[]): string; + (...text: unknown[]): string; (text: TemplateStringsArray, ...placeholders: unknown[]): string; constructor: ChalkConstructor; enabled: boolean; From a5192264ea49574ee2cd79735c1dfd9c40a97cf7 Mon Sep 17 00:00:00 2001 From: Jonathan Van Buren Date: Wed, 26 Dec 2018 14:11:28 +0800 Subject: [PATCH 3/3] Changed typings for flow from string[] -> mixed[] --- index.js.flow | 4 ++-- test/_flow.js | 8 -------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/index.js.flow b/index.js.flow index 622caaa..83e2018 100644 --- a/index.js.flow +++ b/index.js.flow @@ -22,8 +22,8 @@ export type ColorSupport = {| |}; export interface Chalk { - (...text: string[]): string, - (text: TemplateStringsArray, ...placeholders: string[]): string, + (...text: mixed[]): string, + (text: TemplateStringsArray, ...placeholders: mixed[]): string, constructor(options?: ChalkOptions): Chalk, enabled: boolean, level: Level, diff --git a/test/_flow.js b/test/_flow.js index 2cf3cf2..ac76e85 100644 --- a/test/_flow.js +++ b/test/_flow.js @@ -9,10 +9,6 @@ chalk.constructor({level: 1}); new chalk.constructor({enabled: 'true'}); new chalk.constructor({enabled: true}); -// $ExpectError (Can't pass in null) -chalk.underline(null); -chalk.underline('foo'); - // $ExpectError (Can't have typo in chalk method) chalk.rd('foo'); chalk.red('foo'); @@ -29,10 +25,6 @@ chalk.red.bgBlue.underline('foo'); const badCtx = chalk.constructor({level: 4}); const ctx = chalk.constructor({level: 3}); -// $ExpectError (Can't pass in null) -ctx(null); -ctx('foo'); - // $ExpectError (Can't have typo in method name) ctx.gry('foo'); ctx.grey('foo');