[ansi-colors] Update types to v3.2 (#31763)

* [ansi-colors] Move v1 types to sub-dir

* [ansi-colors] Update types to v3.2
This commit is contained in:
Dimitri Benin
2018-12-31 08:03:34 -08:00
committed by Wesley Wigham
parent 9ac607c9d8
commit b30173fbc5
7 changed files with 231 additions and 56 deletions
+33 -28
View File
@@ -1,30 +1,35 @@
import * as colors from 'ansi-colors';
import colors = require('ansi-colors');
let s: string;
colors.red('This is a red string!'); // $ExpectType string
colors.green('This is a red string!'); // $ExpectType string
colors.cyan('This is a cyan string!'); // $ExpectType string
colors.yellow('This is a yellow string!'); // $ExpectType string
s = colors.bgblack("hello");
s = colors.bgblue("hello");
s = colors.bgcyan("hello");
s = colors.bggreen("hello");
s = colors.bgmagenta("hello");
s = colors.bgred("hello");
s = colors.bgwhite("hello");
s = colors.bgyellow("hello");
s = colors.black("hello");
s = colors.blue("hello");
s = colors.bold("hello");
s = colors.cyan("hello");
s = colors.dim("hello");
s = colors.gray("hello");
s = colors.green("hello");
s = colors.grey("hello");
s = colors.hidden("hello");
s = colors.inverse("hello");
s = colors.italic("hello");
s = colors.magenta("hello");
s = colors.red("hello");
s = colors.reset("hello");
s = colors.strikethrough("hello");
s = colors.underline("hello");
s = colors.white("hello");
s = colors.yellow("hello");
colors.bold.red('this is a bold red message'); // $ExpectType string
colors.bold.yellow.italic('this is a bold yellow italicized message'); // $ExpectType string
colors.green.bold.underline('this is a bold green underlined message'); // $ExpectType string
colors.yellow(`foo ${colors.red.bold('red')} bar ${colors.cyan('cyan')} baz`); // $ExpectType string
colors.bold(`foo ${colors.red.dim('bar')} baz`); // $ExpectType string
colors.enabled = false;
colors.visible = false;
colors.hasAnsi(colors.blue('foo')); // $ExpectType boolean
colors.hasColor(colors.blue('foo')); // $ExpectType boolean
colors.unstyle(colors.blue.bold('foo bar baz')); // $ExpectType string
colors.stripColor(colors.blue.bold('foo bar baz')); // $ExpectType string
colors.none('foo'); // $ExpectType string
colors.clear('foo'); // $ExpectType string
colors.noop('foo'); // $ExpectType string
colors.define('reset', [0, 0], 'modifier');
colors.symbols.ballotCross; // $ExpectType string | undefined
colors.symbols.windows.ballotCross; // $ExpectError
colors.symbols.other.ballotCross; // $ExpectType string
colors.symbols.cross; // $ExpectType string
colors.symbols.windows.cross; // $ExpectType string
colors.symbols.other.cross; // $ExpectType string
+107 -27
View File
@@ -1,31 +1,111 @@
// Type definitions for ansi-colors 1.0
// Type definitions for ansi-colors 3.2
// Project: https://github.com/doowb/ansi-colors
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export function bgblack(s: string): string;
export function bgblue(s: string): string;
export function bgcyan(s: string): string;
export function bggreen(s: string): string;
export function bgmagenta(s: string): string;
export function bgred(s: string): string;
export function bgwhite(s: string): string;
export function bgyellow(s: string): string;
export function black(s: string): string;
export function blue(s: string): string;
export function bold(s: string): string;
export function cyan(s: string): string;
export function dim(s: string): string;
export function gray(s: string): string;
export function green(s: string): string;
export function grey(s: string): string;
export function hidden(s: string): string;
export function inverse(s: string): string;
export function italic(s: string): string;
export function magenta(s: string): string;
export function red(s: string): string;
export function reset(s: string): string;
export function strikethrough(s: string): string;
export function underline(s: string): string;
export function white(s: string): string;
export function yellow(s: string): string;
export = colors;
declare const colors: colors.Colors;
declare namespace colors {
type ColorFn = ((text: string) => string) & Colors;
interface Colors {
enabled: boolean;
visible: boolean;
reset: ColorFn;
bold: ColorFn;
dim: ColorFn;
italic: ColorFn;
underline: ColorFn;
inverse: ColorFn;
hidden: ColorFn;
strikethrough: ColorFn;
black: ColorFn;
red: ColorFn;
green: ColorFn;
yellow: ColorFn;
blue: ColorFn;
magenta: ColorFn;
cyan: ColorFn;
white: ColorFn;
gray: ColorFn;
grey: ColorFn;
bgBlack: ColorFn;
bgRed: ColorFn;
bgGreen: ColorFn;
bgYellow: ColorFn;
bgBlue: ColorFn;
bgMagenta: ColorFn;
bgCyan: ColorFn;
bgWhite: ColorFn;
blackBright: ColorFn;
redBright: ColorFn;
greenBright: ColorFn;
yellowBright: ColorFn;
blueBright: ColorFn;
magentaBright: ColorFn;
cyanBright: ColorFn;
whiteBright: ColorFn;
bgBlackBright: ColorFn;
bgRedBright: ColorFn;
bgGreenBright: ColorFn;
bgYellowBright: ColorFn;
bgBlueBright: ColorFn;
bgMagentaBright: ColorFn;
bgCyanBright: ColorFn;
bgWhiteBright: ColorFn;
hasColor(text: string): boolean;
hasAnsi(text: string): boolean;
unstyle(text: string): string;
stripColor(text: string): string;
none(text: string): string;
clear(text: string): string;
noop(text: string): string;
symbols: Symbols & {
windows: WindowsSymbols;
other: OtherPlatformsSymbols;
};
define(
name: string,
codes: [number, number],
type: 'modifier' | 'color' | 'bg' | 'bright' | 'bgBright'
): void;
}
interface WindowsSymbols {
bullet: string;
check: string;
cross: string;
ellipsis: string;
heart: string;
info: string;
line: string;
middot: string;
minus: string;
plus: string;
question: string;
questionSmall: string;
pointer: string;
pointerSmall: string;
warning: string;
}
interface ExtendedSymbols {
ballotCross: string;
questionFull: string;
}
type Symbols = WindowsSymbols & Partial<ExtendedSymbols>;
type OtherPlatformsSymbols = WindowsSymbols & ExtendedSymbols;
}
+1 -1
View File
@@ -20,4 +20,4 @@
"index.d.ts",
"ansi-colors-tests.ts"
]
}
}
+30
View File
@@ -0,0 +1,30 @@
import * as colors from 'ansi-colors';
let s: string;
s = colors.bgblack("hello");
s = colors.bgblue("hello");
s = colors.bgcyan("hello");
s = colors.bggreen("hello");
s = colors.bgmagenta("hello");
s = colors.bgred("hello");
s = colors.bgwhite("hello");
s = colors.bgyellow("hello");
s = colors.black("hello");
s = colors.blue("hello");
s = colors.bold("hello");
s = colors.cyan("hello");
s = colors.dim("hello");
s = colors.gray("hello");
s = colors.green("hello");
s = colors.grey("hello");
s = colors.hidden("hello");
s = colors.inverse("hello");
s = colors.italic("hello");
s = colors.magenta("hello");
s = colors.red("hello");
s = colors.reset("hello");
s = colors.strikethrough("hello");
s = colors.underline("hello");
s = colors.white("hello");
s = colors.yellow("hello");
+31
View File
@@ -0,0 +1,31 @@
// Type definitions for ansi-colors 1.0
// Project: https://github.com/doowb/ansi-colors
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function bgblack(s: string): string;
export function bgblue(s: string): string;
export function bgcyan(s: string): string;
export function bggreen(s: string): string;
export function bgmagenta(s: string): string;
export function bgred(s: string): string;
export function bgwhite(s: string): string;
export function bgyellow(s: string): string;
export function black(s: string): string;
export function blue(s: string): string;
export function bold(s: string): string;
export function cyan(s: string): string;
export function dim(s: string): string;
export function gray(s: string): string;
export function green(s: string): string;
export function grey(s: string): string;
export function hidden(s: string): string;
export function inverse(s: string): string;
export function italic(s: string): string;
export function magenta(s: string): string;
export function red(s: string): string;
export function reset(s: string): string;
export function strikethrough(s: string): string;
export function underline(s: string): string;
export function white(s: string): string;
export function yellow(s: string): string;
+28
View File
@@ -0,0 +1,28 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"ansi-colors": [
"ansi-colors/v1"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"ansi-colors-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }