diff --git a/package.json b/package.json index 6e77c90..099e266 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "node": ">=4" }, "scripts": { - "test": "xo && nyc mocha", + "test": "xo && tsc -p types && nyc mocha", "bench": "matcha benchmark.js", "coveralls": "nyc report --reporter=text-lcov | coveralls" }, @@ -51,9 +51,10 @@ "mocha": "*", "nyc": "^11.0.2", "resolve-from": "^3.0.0", + "typescript": "^2.4.1", "xo": "*" }, - "types": "./index.d.ts", + "types": "./types/index.d.ts", "xo": { "envs": [ "node", diff --git a/index.d.ts b/types/index.d.ts similarity index 100% rename from index.d.ts rename to types/index.d.ts diff --git a/types/test.ts b/types/test.ts new file mode 100644 index 0000000..3ced627 --- /dev/null +++ b/types/test.ts @@ -0,0 +1,31 @@ +import * as chalk from '../.'; + +chalk.underline('foo'); +chalk.red('foo'); +chalk.bgRed('foo'); + +chalk.red`foo`; +chalk.underline`foo`; +chalk`foo`; + +chalk.red.bgGreen.underline('foo'); +chalk.underline.red.bgGreen('foo'); + +chalk.grey('foo'); +chalk.red(0); + +const ctx = chalk.constructor({level: 1}); +ctx('foo'); +ctx.red('foo'); +ctx`foo`; + +chalk.enabled; +chalk.supportsColor; +chalk.level; + +chalk.keyword('orange').bgBlue('foo'); +chalk.hex('#123456').bgBlue('foo'); +chalk.rgb(1, 14, 9).bgBlue('foo'); +chalk.hsl(1, 14, 9).bgBlue('foo'); +chalk.hsv(1, 14, 9).bgBlue('foo'); +chalk.hwb(1, 14, 9).bgBlue('foo'); diff --git a/types/tsconfig.json b/types/tsconfig.json new file mode 100644 index 0000000..af436cc --- /dev/null +++ b/types/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noEmit": true, + "allowJs": true + } +}