Added type definitions for elv (#34153)

This commit is contained in:
Gary Parker
2019-03-25 13:10:11 -04:00
committed by timolinn
parent 557df8f445
commit 541feb9ac3
4 changed files with 60 additions and 0 deletions

14
types/elv/elv-tests.ts Normal file
View File

@@ -0,0 +1,14 @@
import elv = require('elv');
elv(''); // $ExpectType boolean
elv.behavior.enableFalse; // $ExpectedType boolean
elv.behavior.enableNaN; // $ExpectedType boolean
elv.behavior.enableNull; // $ExpectedType boolean
elv.behavior.enableUndefined; // $ExpectedType boolean
elv.coalesce(''); // $ExpectType any
elv.ncoalesce(''); // $ExpectType any
elv.populated(''); // $ExpectType boolean
elv.tryGet([], 0); // $ExpectType any
elv.tryGet([], 0, ''); // $ExpectType any

21
types/elv/index.d.ts vendored Normal file
View File

@@ -0,0 +1,21 @@
// Type definitions for elv 2.2
// Project: https://github.com/dsfields/elv#readme
// Definitions by: Gary Parker <https://github.com/garyaparker>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function elv(val: any): boolean;
declare namespace elv {
const behavior: {
enableFalse: boolean
enableNaN: boolean
enableNull: boolean
enableUndefined: boolean
};
function coalesce(...args: any[]): any;
function ncoalesce(...args: any[]): any;
function populated(val: any): boolean;
function tryGet(val: ReadonlyArray<any>, index: number, def?: any): any;
}
export = elv;

24
types/elv/tsconfig.json Normal file
View File

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

1
types/elv/tslint.json Normal file
View File

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