mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
[just-clone] Adding new Typings for just-clone module (#39996)
* Typings for just-clone * Updated tests * Added more tests * Moved test
This commit is contained in:
parent
efce94ec94
commit
92a0fe0a28
9
types/just-clone/index.d.ts
vendored
Normal file
9
types/just-clone/index.d.ts
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
// Type definitions for just-clone 3.1
|
||||
// Project: https://github.com/angus-c/just#readme
|
||||
// Definitions by: Chris Howard <https://github.com/ConnectivityChris>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
declare function clone<T extends object>(obj: T): T;
|
||||
|
||||
export = clone;
|
||||
25
types/just-clone/just-clone-tests.ts
Normal file
25
types/just-clone/just-clone-tests.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import clone = require('just-clone');
|
||||
|
||||
const array: string[] = [];
|
||||
const object: object = {};
|
||||
|
||||
const arr = [1, 2, 3];
|
||||
const subObj = { aa: 1 };
|
||||
const obj = { a: 3, b: 5, c: arr, d: subObj };
|
||||
|
||||
clone(obj); // $ExpectType { a: number; b: number; c: number[]; d: { aa: number; }; }
|
||||
clone(object); // $ExpectType object
|
||||
clone(array); // $ExpectType string[]
|
||||
clone(() => array); // $ExpectType () => string[]
|
||||
clone(() => {}); // $ExpectType () => void
|
||||
clone({ a: array }); // $ExpectType { a: string[]; }
|
||||
clone([{ a: '' }]); // $ExpectType { a: string; }[]
|
||||
|
||||
// Incorrect types
|
||||
clone(); // $ExpectError
|
||||
clone(1); // $ExpectError
|
||||
clone(''); // $ExpectError
|
||||
clone(true); // $ExpectError
|
||||
clone(false); // $ExpectError
|
||||
clone(null); // $ExpectError
|
||||
clone(undefined); // $ExpectError
|
||||
23
types/just-clone/tsconfig.json
Normal file
23
types/just-clone/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"just-clone-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/just-clone/tslint.json
Normal file
1
types/just-clone/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user