Merge pull request #25894 from pe8ter/just-extend

Add typings for just-extend.
This commit is contained in:
Daniel Rosenwasser
2018-05-23 22:45:28 -07:00
committed by GitHub
4 changed files with 87 additions and 0 deletions

11
types/just-extend/index.d.ts vendored Normal file
View 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;

View 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

View 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"
]
}

View File

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