Skip to content

Commit

Permalink
Add TypeScript types
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Oct 1, 2021
1 parent 548a5c1 commit 475fcbf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
31 changes: 31 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
export type Format = (string: string) => string;

export const reset: Format;
export const bold: Format;
export const dim: Format;
export const italic: Format;
export const underline: Format;
export const overline: Format;
export const inverse: Format;
export const hidden: Format;
export const strikethrough: Format;

export const black: Format;
export const red: Format;
export const green: Format;
export const yellow: Format;
export const blue: Format;
export const magenta: Format;
export const cyan: Format;
export const white: Format;
export const gray: Format;

export const bgBlack: Format;
export const bgRed: Format;
export const bgGreen: Format;
export const bgYellow: Format;
export const bgBlue: Format;
export const bgMagenta: Format;
export const bgCyan: Format;
export const bgWhite: Format;
export const bgGray: Format;
4 changes: 4 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import {expectType} from 'tsd';
import * as colors from './index.js';

expectType<string>(colors.red('x'));
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"scripts": {
"test": "xo && ava"
"test": "xo && ava && tsd"
},
"files": [
"index.js",
Expand Down Expand Up @@ -44,6 +44,7 @@
],
"devDependencies": {
"ava": "^3.15.0",
"tsd": "^0.17.0",
"xo": "^0.44.0"
}
}

0 comments on commit 475fcbf

Please sign in to comment.