Merge pull request #32476 from Hinaser/uuidv4

[uuidv4] Add types
This commit is contained in:
Benjamin Lichtman
2019-01-28 08:41:40 -08:00
committed by GitHub
4 changed files with 55 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
// Type definitions for uuidv4 2.0
// Project: https://github.com/thenativeweb/uuidv4#readme
// Definitions by: Rindo Hinase <https://github.com/Hinaser>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = uuidv4;
declare function uuidv4(): string;
declare namespace uuidv4 {
type EmptyUUIDv4 = '00000000-0000-0000-0000-000000000000';
function is(value: string): boolean;
function empty(): string;
function fromString(text: string): string;
}
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"strictFunctionTypes": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"uuidv4-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+13
View File
@@ -0,0 +1,13 @@
import * as uuidv4 from 'uuidv4'; // uuidv4 is () => string
// $ExpectType string
uuidv4();
// $ExpectType string
uuidv4.empty();
// $ExpectType boolean
uuidv4.is('00000000-0000-0000-0000-000000000000');
// $ExpectType string
uuidv4.fromString("test");