Export styles from ansi-styles (#567)

This commit is contained in:
LitoMore 2022-10-12 17:35:02 +08:00 committed by GitHub
parent 92c55db46f
commit 6e0df055f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 219 additions and 115 deletions

View file

@ -1,5 +1,9 @@
import {expectType, expectAssignable, expectError} from 'tsd';
import chalk, {Chalk, ChalkInstance, Color, ColorInfo, ColorSupport, ColorSupportLevel, chalkStderr, supportsColor, supportsColorStderr} from './index.js';
import {expectType, expectAssignable, expectError, expectDeprecated} from 'tsd';
import chalk, {
Chalk, ChalkInstance, ColorInfo, ColorSupport, ColorSupportLevel, chalkStderr, supportsColor, supportsColorStderr,
ModifierName, ForegroundColorName, BackgroundColorName, ColorName,
Modifiers,
} from './index.js';
// - supportsColor -
expectType<ColorInfo>(supportsColor);
@ -141,6 +145,20 @@ expectType<string>(chalk.underline``);
expectType<string>(chalk.red.bgGreen.bold`Hello {italic.blue ${name}}`);
expectType<string>(chalk.strikethrough.cyanBright.bgBlack`Works with {reset {bold numbers}} {bold.red ${1}}`);
// -- Color types ==
expectAssignable<Color>('red');
expectError<Color>('hotpink');
// -- Modifiers types
expectAssignable<ModifierName>('strikethrough');
expectError<ModifierName>('delete');
// -- Foreground types
expectAssignable<ForegroundColorName>('red');
expectError<ForegroundColorName>('pink');
// -- Background types
expectAssignable<BackgroundColorName>('bgRed');
expectError<BackgroundColorName>('bgPink');
// -- Color types --
expectAssignable<ColorName>('red');
expectAssignable<ColorName>('bgRed');
expectError<ColorName>('hotpink');
expectError<ColorName>('bgHotpink');