[array-same] Add types (#63236)

This commit is contained in:
Dimitri B
2022-11-14 17:54:37 +01:00
committed by GitHub
parent b4a0d04424
commit e56e050ee7
4 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
import hasSameElements = require('array-same');
hasSameElements([1, 2], [2, 1]); // $ExpectType boolean
hasSameElements(['a', 'b'], ['b', 'c']); // $ExpectType boolean
hasSameElements([1, 2, 3], [1, 2]); // $ExpectType boolean
hasSameElements([1, 2] as const, [1, 2, 3] as const); // $ExpectType boolean
hasSameElements([1, 2, 3], [1, 2], [1, 2]); // $ExpectType boolean

17
types/array-same/index.d.ts vendored Normal file
View File

@@ -0,0 +1,17 @@
// Type definitions for array-same 1.0
// Project: https://github.com/dfcreative/array-same
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = hasSameElements;
/**
* Check one or more array whether they have the same items as `source`.
*
* @example
* import hasSameElements = require('array-same');
*
* hasSameElements([1, 2], [2, 1]); // true
* hasSameElements([1, 2, 3], [1, 2]); // false
*/
declare function hasSameElements<T>(source: readonly T[], ...args: ReadonlyArray<readonly T[]>): boolean;

View 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",
"array-same-tests.ts"
]
}

View File

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