Add typings for npm module uid2 (#36207)

* Add typings for npm module uid2

* Add callback parameter to uid typing

* Refactor uid2 typings to different style

* Enable dt-header lint rule @types/uid2

* Fix tests
This commit is contained in:
Levi Bostian 2019-07-18 19:45:07 -05:00 committed by Ron Buckton
parent 64fc67104c
commit 7619b2d6f5
4 changed files with 43 additions and 0 deletions

9
types/uid2/index.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
// Type definitions for uid2 0.0
// Project: https://github.com/coreh/uid2
// Definitions by: Levi Bostian <https://github.com/levibostian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function uid2(length: number): string;
declare function uid2(length: number, callback: (err: Error | null, result?: string) => void): void;
export = uid2;

23
types/uid2/tsconfig.json Normal file
View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"uid2-tests.ts"
]
}

3
types/uid2/tslint.json Normal file
View File

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

8
types/uid2/uid2-tests.ts Normal file
View File

@ -0,0 +1,8 @@
import uid2 = require('uid2');
uid2(20); // $ExpectType string
uid2(20, (error, result) => {
error; // $ExpectType Error | null
result; // $ExpectType string | undefined
});