mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-31 11:07:32 +08:00
Merge pull request #25894 from pe8ter/just-extend
Add typings for just-extend.
This commit is contained in:
11
types/just-extend/index.d.ts
vendored
Normal file
11
types/just-extend/index.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Type definitions for just-extend 1.1
|
||||
// Project: https://github.com/angus-c/just#readme
|
||||
// Definitions by: Peter Safranek <https://github.com/pe8ter>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
declare function extend(obj1: object, ...objn: any[]): object;
|
||||
|
||||
declare function extend(deep: boolean, obj1: object, ...objn: any[]): object;
|
||||
|
||||
export = extend;
|
||||
52
types/just-extend/just-extend-tests.ts
Normal file
52
types/just-extend/just-extend-tests.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import extend = require("just-extend");
|
||||
|
||||
// Pass single `object`.
|
||||
extend({}); // $ExpectType object
|
||||
extend([]); // $ExpectType object
|
||||
extend(() => {}); // $ExpectType object
|
||||
|
||||
// Pass single `object`, then `any`.
|
||||
extend({}, 0); // $ExpectType object
|
||||
extend({}, ""); // $ExpectType object
|
||||
extend({}, false); // $ExpectType object
|
||||
extend({}, null); // $ExpectType object
|
||||
extend({}, undefined); // $ExpectType object
|
||||
extend({}, {}); // $ExpectType object
|
||||
extend({}, []); // $ExpectType object
|
||||
extend({}, () => {}); // $ExpectType object
|
||||
|
||||
// Pass variadic args.
|
||||
extend({}, 0, "", false, null, undefined, {}, [], () => {}); // $ExpectType object
|
||||
|
||||
// Pass `boolean`, then single `object`.
|
||||
extend(true, {}); // $ExpectType object
|
||||
extend(true, []); // $ExpectType object
|
||||
extend(true, () => {}); // $ExpectType object
|
||||
|
||||
// Pass `boolean`, single `object`, then `any`.
|
||||
extend(true, {}, 0); // $ExpectType object
|
||||
extend(true, {}, ""); // $ExpectType object
|
||||
extend(true, {}, false); // $ExpectType object
|
||||
extend(true, {}, null); // $ExpectType object
|
||||
extend(true, {}, undefined); // $ExpectType object
|
||||
extend(true, {}, {}); // $ExpectType object
|
||||
extend(true, {}, []); // $ExpectType object
|
||||
extend(true, {}, () => {}); // $ExpectType object
|
||||
|
||||
// Pass `boolean`, then variadic args.
|
||||
extend(true, {}, 0, "", false, null, undefined, {}, [], () => {}); // $ExpectType object
|
||||
|
||||
// Incorrect extendee `object`.
|
||||
extend(); // $ExpectError
|
||||
extend(0); // $ExpectError
|
||||
extend(""); // $ExpectError
|
||||
extend(false); // $ExpectError
|
||||
extend(null); // $ExpectError
|
||||
extend(undefined); // $ExpectError
|
||||
|
||||
// Pass `boolean` with incorrect extendee `object`.
|
||||
extend(true, 0); // $ExpectError
|
||||
extend(true, ""); // $ExpectError
|
||||
extend(true, false); // $ExpectError
|
||||
extend(true, null); // $ExpectError
|
||||
extend(true, undefined); // $ExpectError
|
||||
23
types/just-extend/tsconfig.json
Normal file
23
types/just-extend/tsconfig.json
Normal 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",
|
||||
"just-extend-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/just-extend/tslint.json
Normal file
1
types/just-extend/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user