fix(types): change overload order for better implicit any inference
This commit is contained in:
parent
381f4ab630
commit
f6b0e45cdd
2 changed files with 18 additions and 9 deletions
24
types/index.d.ts
vendored
24
types/index.d.ts
vendored
|
|
@ -13,20 +13,26 @@ export interface ChalkOptions {
|
||||||
level?: Level;
|
level?: Level;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Chalk {
|
export interface ChalkConstructor extends Chalk {
|
||||||
new (options?: ChalkOptions): Chalk;
|
new (options?: ChalkOptions): Chalk;
|
||||||
(options?: ChalkOptions): Chalk;
|
(options?: ChalkOptions): Chalk;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ColorSupport {
|
||||||
|
level: Level;
|
||||||
|
hasBasic: boolean;
|
||||||
|
has256: boolean;
|
||||||
|
has16m: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Chalk {
|
||||||
(...text: string[]): string;
|
(...text: string[]): string;
|
||||||
(text: TemplateStringsArray, ...placeholders: string[]): string;
|
(text: TemplateStringsArray, ...placeholders: string[]): string;
|
||||||
constructor: Chalk;
|
new (options?: ChalkOptions): Chalk;
|
||||||
|
(options: ChalkOptions): Chalk;
|
||||||
|
constructor: ChalkConstructor;
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
level: Level;
|
level: Level;
|
||||||
supportsColor: {
|
|
||||||
level: Level;
|
|
||||||
hasBasic: boolean;
|
|
||||||
has256: boolean;
|
|
||||||
has16m: boolean;
|
|
||||||
};
|
|
||||||
rgb(r: number, g: number, b: number): Chalk;
|
rgb(r: number, g: number, b: number): Chalk;
|
||||||
hsl(h: number, s: number, l: number): Chalk;
|
hsl(h: number, s: number, l: number): Chalk;
|
||||||
hsv(h: number, s: number, v: number): Chalk;
|
hsv(h: number, s: number, v: number): Chalk;
|
||||||
|
|
@ -86,6 +92,6 @@ export interface Chalk {
|
||||||
bgWhiteBright: Chalk;
|
bgWhiteBright: Chalk;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare const chalk: Chalk
|
declare const chalk: Chalk & { supportsColor: ColorSupport };
|
||||||
|
|
||||||
export default chalk
|
export default chalk
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,9 @@ let chalkInstance = new chalk();
|
||||||
chalkInstance = new chalk.constructor();
|
chalkInstance = new chalk.constructor();
|
||||||
chalkInstance = chalk.constructor();
|
chalkInstance = chalk.constructor();
|
||||||
|
|
||||||
|
let x = 'imastring';
|
||||||
|
x = chalk();
|
||||||
|
|
||||||
chalk.enabled;
|
chalk.enabled;
|
||||||
chalk.level;
|
chalk.level;
|
||||||
chalk.supportsColor.level;
|
chalk.supportsColor.level;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue