diff --git a/types/set-value/index.d.ts b/types/set-value/index.d.ts new file mode 100644 index 0000000000..be3f2c8b0a --- /dev/null +++ b/types/set-value/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for set-value 2.0 +// Project: https://github.com/jonschlinkert/set-value +// Definitions by: Daniel Rosenwasser +// 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(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; diff --git a/types/set-value/set-value-tests.ts b/types/set-value/set-value-tests.ts new file mode 100644 index 0000000000..b2b6e78166 --- /dev/null +++ b/types/set-value/set-value-tests.ts @@ -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); +} diff --git a/types/set-value/tsconfig.json b/types/set-value/tsconfig.json new file mode 100644 index 0000000000..38bec2daa7 --- /dev/null +++ b/types/set-value/tsconfig.json @@ -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" + ] +} diff --git a/types/set-value/tslint.json b/types/set-value/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/set-value/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }