From 42e60e528305fdf3082d04a50f9e830c1ac9d595 Mon Sep 17 00:00:00 2001 From: Dimitri Benin Date: Sat, 22 Jul 2017 11:22:57 +0200 Subject: [PATCH] [sparkly] introduce typings (#18291) * [sparkly] introduce typings * [sparkly] restrict input type to allow all types from examples but not more than that --- types/sparkly/index.d.ts | 16 ++++++++++++++++ types/sparkly/sparkly-tests.ts | 7 +++++++ types/sparkly/tsconfig.json | 22 ++++++++++++++++++++++ types/sparkly/tslint.json | 1 + 4 files changed, 46 insertions(+) create mode 100644 types/sparkly/index.d.ts create mode 100644 types/sparkly/sparkly-tests.ts create mode 100644 types/sparkly/tsconfig.json create mode 100644 types/sparkly/tslint.json diff --git a/types/sparkly/index.d.ts b/types/sparkly/index.d.ts new file mode 100644 index 0000000000..3e1e5529a6 --- /dev/null +++ b/types/sparkly/index.d.ts @@ -0,0 +1,16 @@ +// Type definitions for sparkly 3.1 +// Project: https://github.com/sindresorhus/sparkly +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = sparkly; + +declare function sparkly(numbers: Array, options?: sparkly.Options): string; + +declare namespace sparkly { + interface Options { + min?: number; + max?: number; + style?: 'fire'; + } +} diff --git a/types/sparkly/sparkly-tests.ts b/types/sparkly/sparkly-tests.ts new file mode 100644 index 0000000000..cd5fa262e0 --- /dev/null +++ b/types/sparkly/sparkly-tests.ts @@ -0,0 +1,7 @@ +import sparkly = require('sparkly'); + +let str: string; +str = sparkly([0, 3, 5, 8, 4, 3, 4, 10]); +str = sparkly([0, 3, 5, '', 4, 3, 4, 10]); +str = sparkly([1, 2, 3, 4, 5], {min: 0, max: 10}); +str = sparkly([1, 2, 3, 4, 5, 6, 7, 8], {style: 'fire'}); diff --git a/types/sparkly/tsconfig.json b/types/sparkly/tsconfig.json new file mode 100644 index 0000000000..f439b0a2e7 --- /dev/null +++ b/types/sparkly/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "sparkly-tests.ts" + ] +} diff --git a/types/sparkly/tslint.json b/types/sparkly/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/sparkly/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }