mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 13:00:19 +00:00
Add just-map-values and just-safe-set types (#42739)
* Add some just functions * Fix some tests * Fixes for code review * Fix tests
This commit is contained in:
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for just-map-values 1.1
|
||||
// Project: https://github.com/angus-c/just#readme
|
||||
// Definitions by: Roman Lerchster <https://github.com/wa4-fearless-otter>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function map<T extends {}>(item: T, callback: (value: any, key: string, object: T) => any): {};
|
||||
|
||||
export = map;
|
||||
@@ -0,0 +1,11 @@
|
||||
import map = require("just-map-values");
|
||||
|
||||
const obj = {foo: {bar: []}};
|
||||
|
||||
map(obj, (value) => value); // $ExpectType {}
|
||||
map(obj, (value, key, object) => ''); // $ExpectType {}
|
||||
|
||||
// Incorrect argument
|
||||
map(); // $ExpectError
|
||||
map(obj); // $ExpectError
|
||||
map(obj, ''); // $ExpectError
|
||||
@@ -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",
|
||||
"just-map-values-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for just-safe-set 2.1
|
||||
// Project: https://github.com/angus-c/just#readme
|
||||
// Definitions by: Roman Lerchster <https://github.com/wa4-fearless-otter>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function set(item: any[] | {}, target: string | symbol | Array<string | symbol>, value: any): boolean;
|
||||
|
||||
export = set;
|
||||
@@ -0,0 +1,22 @@
|
||||
import set = require("just-safe-set");
|
||||
|
||||
const arr = ['one', 'two'];
|
||||
const obj = {foo: {bar: arr}};
|
||||
|
||||
// Pass single `object`.
|
||||
set(arr, '0', {}); // $ExpectType boolean
|
||||
set(arr, ['0'], ''); // $ExpectType boolean
|
||||
set(obj, 'foo.bar', 0); // $ExpectType boolean
|
||||
set(obj, 'foo.bar.0', 1); // $ExpectType boolean
|
||||
|
||||
// Incorrect argument
|
||||
set(); // $ExpectError
|
||||
set(obj); // $ExpectError
|
||||
set([]); // $ExpectError
|
||||
set({}); // $ExpectError
|
||||
set(obj, 3); // $ExpectError
|
||||
set(obj, [3]); // $ExpectError
|
||||
set(false); // $ExpectError
|
||||
set(null); // $ExpectError
|
||||
set(undefined); // $ExpectError
|
||||
set(obj, 'foo.bar'); // $ExpectError
|
||||
@@ -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",
|
||||
"just-safe-set-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user