mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 11:51:10 +08:00
Merge pull request #28094 from rsolomon/rsolomon/shallow-equals
Add definition for shallow-equals
This commit is contained in:
12
types/shallow-equals/index.d.ts
vendored
Normal file
12
types/shallow-equals/index.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
// Type definitions for shallow-equals 1.0
|
||||
// Project: https://github.com/hughsk/shallow-equals
|
||||
// Definitions by: Ross Solomon <https://github.com/rsolomon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = shallow_equals;
|
||||
|
||||
declare function shallow_equals<A, B>(
|
||||
a?: A,
|
||||
b?: B,
|
||||
compare?: (objA: A, objB: B) => boolean,
|
||||
): boolean;
|
||||
19
types/shallow-equals/shallow-equals-tests.ts
Normal file
19
types/shallow-equals/shallow-equals-tests.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import shallowEquals = require('shallow-equals');
|
||||
|
||||
interface A {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
interface B {
|
||||
foo: string;
|
||||
bar?: string;
|
||||
}
|
||||
|
||||
const a: A = { foo: 'bar' };
|
||||
const b: B = { foo: 'baz' };
|
||||
function compare(a: A, b: B) {
|
||||
return false;
|
||||
}
|
||||
|
||||
shallowEquals(a, b);
|
||||
shallowEquals(a, b, compare);
|
||||
16
types/shallow-equals/tsconfig.json
Normal file
16
types/shallow-equals/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "shallow-equals-tests.ts"]
|
||||
}
|
||||
3
types/shallow-equals/tslint.json
Normal file
3
types/shallow-equals/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Reference in New Issue
Block a user