[sparkly] introduce typings (#18291)

* [sparkly] introduce typings

* [sparkly] restrict input type to allow all types from examples but not more than that
This commit is contained in:
Dimitri Benin
2017-07-22 11:22:57 +02:00
committed by Wesley Wigham
parent c469f9c606
commit 42e60e5283
4 changed files with 46 additions and 0 deletions

16
types/sparkly/index.d.ts vendored Normal file
View File

@@ -0,0 +1,16 @@
// Type definitions for sparkly 3.1
// Project: https://github.com/sindresorhus/sparkly
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = sparkly;
declare function sparkly(numbers: Array<number | ''>, options?: sparkly.Options): string;
declare namespace sparkly {
interface Options {
min?: number;
max?: number;
style?: 'fire';
}
}

View File

@@ -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'});

View File

@@ -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"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }