mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 14:20:12 +00:00
Add typings for just-pick (#30605)
This commit is contained in:
committed by
Pranav Senthilnathan
parent
0ce9dbee58
commit
ea65f55484
11
types/just-pick/index.d.ts
vendored
Normal file
11
types/just-pick/index.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
// Type definitions for just-pick 2.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.1
|
||||
|
||||
declare function pick<T, U extends keyof T>(obj: T, select: U[]): Pick<T, U>;
|
||||
|
||||
declare function pick<T, U extends keyof T>(obj: T, select1: U, ...selectn: U[]): Pick<T, U>;
|
||||
|
||||
export = pick;
|
||||
26
types/just-pick/just-pick-tests.ts
Normal file
26
types/just-pick/just-pick-tests.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import pick = require("just-pick");
|
||||
|
||||
const a = "a";
|
||||
const b = "b";
|
||||
const c = "c";
|
||||
const obj = { a, b };
|
||||
|
||||
pick(obj, []); // $ExpectType Pick<{ a: string; b: string; }, never>
|
||||
pick(obj, [a]); // $ExpectType Pick<{ a: string; b: string; }, "a">
|
||||
pick(obj, [a, a]); // $ExpectType Pick<{ a: string; b: string; }, "a">
|
||||
pick(obj, [a, b]); // $ExpectType Pick<{ a: string; b: string; }, "a" | "b">
|
||||
pick(obj, [a, b, c]); // $ExpectError
|
||||
|
||||
pick(obj, a); // $ExpectType Pick<{ a: string; b: string; }, "a">
|
||||
pick(obj, a, a); // $ExpectType Pick<{ a: string; b: string; }, "a">
|
||||
pick(obj, a, b); // $ExpectType Pick<{ a: string; b: string; }, "a" | "b">
|
||||
pick(obj, a, b, c); // $ExpectError
|
||||
|
||||
pick(); // $ExpectError
|
||||
pick(obj); // $ExpectError
|
||||
pick(obj, 0); // $ExpectError
|
||||
pick(obj, false); // $ExpectError
|
||||
pick(obj, null); // $ExpectError
|
||||
pick(obj, undefined); // $ExpectError
|
||||
pick(obj, {}); // $ExpectError
|
||||
pick(obj, () => {}); // $ExpectError
|
||||
23
types/just-pick/tsconfig.json
Normal file
23
types/just-pick/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-pick-tests.ts"
|
||||
]
|
||||
}
|
||||
6
types/just-pick/tslint.json
Normal file
6
types/just-pick/tslint.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"file-name-casing": false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user