clone-deep npm package typings (#33750)

* clone-deep types

* inlined InstanceClone
This commit is contained in:
Piotr 2019-03-11 19:03:34 +01:00 committed by Wesley Wigham
parent a3528daaf0
commit d0af366f23
4 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import cloneDeep from 'clone-deep';
cloneDeep<object>(Object.create(null)); // $ExpectType object
cloneDeep<object>({}); // $ExpectType object
cloneDeep({}); // $ExpectType {}
cloneDeep(new Array()); // $ExpectType any[]
cloneDeep<any[]>([]); // $ExpectType any[]
cloneDeep<number>(42); // $ExpectType number
cloneDeep<string>('clone'); // $ExpectType string
cloneDeep<object>({}, true); // $ExpectType object
cloneDeep({}, true); // $ExpectType {}
cloneDeep<number>(42, true); // $ExpectType number
cloneDeep<object>({}, _ => ({})); // $ExpectType object
cloneDeep({}, _ => ({})); // $ExpectType {}
cloneDeep<object>({}, _ => 42); // $ExpectError
cloneDeep(42, _ => ({})); // $ExpectError

10
types/clone-deep/index.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
// Type definitions for clone-deep 4.0
// Project: https://github.com/jonschlinkert/clone-deep
// Definitions by: Tanfonto <https://github.com/tanfonto>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
export default function cloneDeep<T>(
val: T,
instanceClone?: true | ((val: T) => T)
): T;

View File

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

View File

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