kibana/packages/kbn-safer-lodash-set/test/fp_setWith.ts
Spencer 9003353729
rename @elastic/* packages to @kbn/* (#138957)
* rename @elastic/* packages to @kbn/*

* update yarn.lock

* [CI] Auto-commit changed files from 'node scripts/generate packages_build_manifest'

* update lint task

* review feedback

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-08-18 08:54:42 -07:00

40 lines
2 KiB
TypeScript

/*
* Elasticsearch B.V licenses this file to you under the MIT License.
* See `packages/kbn-safer-lodash-set/LICENSE` for more information.
*/
import { expectType } from 'tsd';
import setWith from '../fp/setWith';
const someObj: object = {};
const anyValue: any = 'any value';
function customizer(value: any, key: string, obj: object) {
expectType<any>(value);
expectType<string>(key);
expectType<object>(obj);
}
expectType<object>(setWith(customizer, 'a.b.c', anyValue, someObj));
expectType<object>(setWith(customizer)('a.b.c', anyValue, someObj));
expectType<object>(setWith(customizer)('a.b.c')(anyValue, someObj));
expectType<object>(setWith(customizer)('a.b.c')(anyValue)(someObj));
expectType<object>(setWith(customizer, 'a.b.c')(anyValue)(someObj));
expectType<object>(setWith(customizer, 'a.b.c', anyValue)(someObj));
expectType<object>(setWith(customizer, 'a.b.c')(anyValue, someObj));
expectType<object>(setWith(customizer, ['a.b.c'], anyValue, someObj));
expectType<object>(setWith(customizer)(['a.b.c'])(anyValue, someObj));
expectType<object>(setWith(customizer)(['a.b.c'], anyValue, someObj));
expectType<object>(setWith(customizer)(['a.b.c'])(anyValue)(someObj));
expectType<object>(setWith(customizer, ['a.b.c'])(anyValue)(someObj));
expectType<object>(setWith(customizer, ['a.b.c'], anyValue)(someObj));
expectType<object>(setWith(customizer, ['a.b.c'])(anyValue, someObj));
expectType<object>(setWith(customizer, ['a.b.c', 2, Symbol('hep')], anyValue, someObj));
expectType<object>(setWith(customizer)(['a.b.c', 2, Symbol('hep')])(anyValue, someObj));
expectType<object>(setWith(customizer)(['a.b.c', 2, Symbol('hep')], anyValue, someObj));
expectType<object>(setWith(customizer)(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj));
expectType<object>(setWith(customizer, ['a.b.c', 2, Symbol('hep')])(anyValue)(someObj));
expectType<object>(setWith(customizer, ['a.b.c', 2, Symbol('hep')], anyValue)(someObj));
expectType<object>(setWith(customizer, ['a.b.c', 2, Symbol('hep')])(anyValue, someObj));