Added 'set-value'.

This commit is contained in:
Daniel Rosenwasser 2018-02-17 00:51:03 -08:00
parent 423ace8fe7
commit afa07abdbb
4 changed files with 59 additions and 0 deletions

23
types/set-value/index.d.ts vendored Normal file
View File

@ -0,0 +1,23 @@
// Type definitions for set-value 2.0
// Project: https://github.com/jonschlinkert/set-value
// Definitions by: Daniel Rosenwasser <https://github.com/DanielRosenwasser>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
export = set;
// Technically, everything will fall to the last overload,
// but the first one can be useful for signature help.
/**
* @param object The object to set `value` on
* @param prop The property to set.
* @param value The value to set on `object[prop]`
*/
declare function set<T, K extends keyof T>(object: T, prop: K, value: T[K]): void;
/**
* @param object The object to set `value` on
* @param prop The property to set. Dot-notation may be used.
* @param value The value to set on `object[prop]`
*/
declare function set(object: object, prop: string, value: any): void;

View File

@ -0,0 +1,12 @@
import set = require("set-value");
{
const obj = {};
set(obj, "a.b.c", "d");
set({}, "a\\.b.c", "d");
}
{
const obj = { a: 100 };
set(obj, "a", 1000);
}

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

View File

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