fix(types): supportsColor is top‑level only
This commit is contained in:
parent
98628d9f08
commit
1b168d47db
2 changed files with 6 additions and 12 deletions
16
index.d.ts
vendored
16
index.d.ts
vendored
|
|
@ -70,11 +70,11 @@ declare namespace chalk {
|
||||||
has16m: boolean;
|
has16m: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ChalkTemplateFunction = (text: TemplateStringsArray, ...placeholders: unknown[]) => string;
|
||||||
|
|
||||||
interface Chalk {
|
interface Chalk {
|
||||||
(...text: unknown[]): string;
|
(...text: unknown[]): string;
|
||||||
|
|
||||||
(text: TemplateStringsArray, ...placeholders: unknown[]): string;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Return a new Chalk instance.
|
Return a new Chalk instance.
|
||||||
*/
|
*/
|
||||||
|
|
@ -99,11 +99,9 @@ declare namespace chalk {
|
||||||
@param color - Hexadecimal value representing the desired color.
|
@param color - Hexadecimal value representing the desired color.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
```
|
|
||||||
import chalk = require('chalk');
|
import chalk = require('chalk');
|
||||||
|
|
||||||
chalk.hex('#DEADED');
|
chalk.hex('#DEADED');
|
||||||
```
|
|
||||||
*/
|
*/
|
||||||
hex(color: string): this;
|
hex(color: string): this;
|
||||||
|
|
||||||
|
|
@ -113,11 +111,9 @@ declare namespace chalk {
|
||||||
@param color - Keyword value representing the desired color.
|
@param color - Keyword value representing the desired color.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
```
|
|
||||||
import chalk = require('chalk');
|
import chalk = require('chalk');
|
||||||
|
|
||||||
chalk.keyword('orange');
|
chalk.keyword('orange');
|
||||||
```
|
|
||||||
*/
|
*/
|
||||||
keyword(color: string): this;
|
keyword(color: string): this;
|
||||||
|
|
||||||
|
|
@ -147,11 +143,9 @@ declare namespace chalk {
|
||||||
@param color - Hexadecimal value representing the desired color.
|
@param color - Hexadecimal value representing the desired color.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
```
|
|
||||||
import chalk = require('chalk');
|
import chalk = require('chalk');
|
||||||
|
|
||||||
chalk.bgHex('#DEADED');
|
chalk.bgHex('#DEADED');
|
||||||
```
|
|
||||||
*/
|
*/
|
||||||
bgHex(color: string): this;
|
bgHex(color: string): this;
|
||||||
|
|
||||||
|
|
@ -161,11 +155,9 @@ declare namespace chalk {
|
||||||
@param color - Keyword value representing the desired color.
|
@param color - Keyword value representing the desired color.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
```
|
|
||||||
import chalk = require('chalk');
|
import chalk = require('chalk');
|
||||||
|
|
||||||
chalk.bgKeyword('orange');
|
chalk.bgKeyword('orange');
|
||||||
```
|
|
||||||
*/
|
*/
|
||||||
bgKeyword(color: string): this;
|
bgKeyword(color: string): this;
|
||||||
|
|
||||||
|
|
@ -273,13 +265,15 @@ declare namespace chalk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare type NoThis<T> = {[K in keyof T]: T[K] extends T ? T : T[K]};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Main Chalk object that allows to chain styles together.
|
Main Chalk object that allows to chain styles together.
|
||||||
Call the last one as a method with a string argument.
|
Call the last one as a method with a string argument.
|
||||||
Order doesn't matter, and later styles take precedent in case of a conflict.
|
Order doesn't matter, and later styles take precedent in case of a conflict.
|
||||||
This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||||
*/
|
*/
|
||||||
declare const chalk: chalk.Chalk & {
|
declare const chalk: NoThis<chalk.Chalk> & chalk.ChalkTemplateFunction & {
|
||||||
supportsColor: chalk.ColorSupport;
|
supportsColor: chalk.ColorSupport;
|
||||||
Level: typeof LevelEnum;
|
Level: typeof LevelEnum;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import {expectType} from 'tsd';
|
||||||
import chalk = require('.');
|
import chalk = require('.');
|
||||||
|
|
||||||
// - Helpers -
|
// - Helpers -
|
||||||
type colorReturn = chalk.Chalk & {supportsColor: chalk.ColorSupport};
|
type colorReturn = chalk.Chalk & {supportsColor?: never};
|
||||||
|
|
||||||
// - Level -
|
// - Level -
|
||||||
expectType<number>(chalk.Level.None);
|
expectType<number>(chalk.Level.None);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue