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;
|
||||
}
|
||||
|
||||
export interface Chalk {
|
||||
export interface ChalkConstructor extends Chalk {
|
||||
new (options?: ChalkOptions): Chalk;
|
||||
(options?: ChalkOptions): Chalk;
|
||||
}
|
||||
|
||||
export interface ColorSupport {
|
||||
level: Level;
|
||||
hasBasic: boolean;
|
||||
has256: boolean;
|
||||
has16m: boolean;
|
||||
}
|
||||
|
||||
export interface Chalk {
|
||||
(...text: string[]): string;
|
||||
(text: TemplateStringsArray, ...placeholders: string[]): string;
|
||||
constructor: Chalk;
|
||||
new (options?: ChalkOptions): Chalk;
|
||||
(options: ChalkOptions): Chalk;
|
||||
constructor: ChalkConstructor;
|
||||
enabled: boolean;
|
||||
level: Level;
|
||||
supportsColor: {
|
||||
level: Level;
|
||||
hasBasic: boolean;
|
||||
has256: boolean;
|
||||
has16m: boolean;
|
||||
};
|
||||
rgb(r: number, g: number, b: number): Chalk;
|
||||
hsl(h: number, s: number, l: number): Chalk;
|
||||
hsv(h: number, s: number, v: number): Chalk;
|
||||
|
|
@ -86,6 +92,6 @@ export interface Chalk {
|
|||
bgWhiteBright: Chalk;
|
||||
}
|
||||
|
||||
declare const chalk: Chalk
|
||||
declare const chalk: Chalk & { supportsColor: ColorSupport };
|
||||
|
||||
export default chalk
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ let chalkInstance = new chalk();
|
|||
chalkInstance = new chalk.constructor();
|
||||
chalkInstance = chalk.constructor();
|
||||
|
||||
let x = 'imastring';
|
||||
x = chalk();
|
||||
|
||||
chalk.enabled;
|
||||
chalk.level;
|
||||
chalk.supportsColor.level;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue