Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typings for object-merge #247

Merged
merged 1 commit into from
May 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/object-merge/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Definitions by: nokazn <https://github.com/nokazn>
declare function merge(obj1: object, ...objs: object[]): object;
export = merge;
54 changes: 54 additions & 0 deletions packages/object-merge/index.tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import merge = require('./index');

// OK

// Single argument
merge({});
merge({ a: 1 });
merge([]);
merge(() => {});
merge(new Map());
merge(new Set());

// Multiple arguments
merge({}, {});
merge({}, { a: 1 });
merge({}, []);
merge({}, () => {});
merge({}, new Map());
merge({}, new Set());
merge({}, { a: 1 }, { a: 2, b: 3 });

// Not OK

// Single argument
// @ts-expect-error
merge();
// @ts-expect-error
merge(0);
// @ts-expect-error
merge('');
// @ts-expect-error
merge(false);
// @ts-expect-error
merge(null);
// @ts-expect-error
merge(undefined);
// @ts-expect-error
merge(Symbol());

// Multiple arguments
// @ts-expect-error
merge({}, 0);
// @ts-expect-error
merge({}, '');
// @ts-expect-error
merge({}, false);
// @ts-expect-error
merge({}, null);
// @ts-expect-error
merge({}, undefined);
// @ts-expect-error
merge({}, Symbol());
// @ts-expect-error
merge({}, {}, null);
1 change: 1 addition & 0 deletions packages/object-merge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.1.0",
"description": "shallow extend an object",
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down