* move test_helpers to the core * create base tsconfig * all tsconfigs use the base one * use test_helpers exposed from the src/core * move getFieldFormatsRegistry to data plugin * add test_utils project * compile types after checkout * add a stub for platform tsconfig.json * fix broken import * fix broken path to the base config * set tsBuildInfoFile for project without outDir * do not commit tsbuildinfo file * do not check output d.ts files * fix type error * use separate config to build types * rollback changes to include paths * mute import zone error * rename files to avoid references to tsd * do not use tsd for type tests * include all ts files in project * run buildRefs before type check to ensure the latest version * store tsbuildinfo locally * update paths to base config * comment out core/tsconfig.json * remove ui path * fix wrong tsbuildinfo path
86 lines
4.2 KiB
TypeScript
86 lines
4.2 KiB
TypeScript
/*
|
|
* Elasticsearch B.V licenses this file to you under the MIT License.
|
|
* See `packages/elastic-safer-lodash-set/LICENSE` for more information.
|
|
*/
|
|
|
|
import { expectType } from 'tsd';
|
|
import { set, setWith, assoc, assocPath } from '../fp';
|
|
|
|
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>(set('a.b.c', anyValue, someObj));
|
|
expectType<object>(set('a.b.c')(anyValue, someObj));
|
|
expectType<object>(set('a.b.c')(anyValue)(someObj));
|
|
expectType<object>(set('a.b.c', anyValue)(someObj));
|
|
|
|
expectType<object>(set(['a.b.c'], anyValue, someObj));
|
|
expectType<object>(set(['a.b.c'])(anyValue, someObj));
|
|
expectType<object>(set(['a.b.c'])(anyValue)(someObj));
|
|
expectType<object>(set(['a.b.c'], anyValue)(someObj));
|
|
|
|
expectType<object>(set(['a.b.c', 2, Symbol('hep')], anyValue, someObj));
|
|
expectType<object>(set(['a.b.c', 2, Symbol('hep')])(anyValue, someObj));
|
|
expectType<object>(set(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj));
|
|
expectType<object>(set(['a.b.c', 2, Symbol('hep')], anyValue)(someObj));
|
|
|
|
expectType<object>(assoc('a.b.c', anyValue, someObj));
|
|
expectType<object>(assoc('a.b.c')(anyValue, someObj));
|
|
expectType<object>(assoc('a.b.c')(anyValue)(someObj));
|
|
expectType<object>(assoc('a.b.c', anyValue)(someObj));
|
|
|
|
expectType<object>(assoc(['a.b.c'], anyValue, someObj));
|
|
expectType<object>(assoc(['a.b.c'])(anyValue, someObj));
|
|
expectType<object>(assoc(['a.b.c'])(anyValue)(someObj));
|
|
expectType<object>(assoc(['a.b.c'], anyValue)(someObj));
|
|
|
|
expectType<object>(assoc(['a.b.c', 2, Symbol('hep')], anyValue, someObj));
|
|
expectType<object>(assoc(['a.b.c', 2, Symbol('hep')])(anyValue, someObj));
|
|
expectType<object>(assoc(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj));
|
|
expectType<object>(assoc(['a.b.c', 2, Symbol('hep')], anyValue)(someObj));
|
|
|
|
expectType<object>(assocPath('a.b.c', anyValue, someObj));
|
|
expectType<object>(assocPath('a.b.c')(anyValue, someObj));
|
|
expectType<object>(assocPath('a.b.c')(anyValue)(someObj));
|
|
expectType<object>(assocPath('a.b.c', anyValue)(someObj));
|
|
|
|
expectType<object>(assocPath(['a.b.c'], anyValue, someObj));
|
|
expectType<object>(assocPath(['a.b.c'])(anyValue, someObj));
|
|
expectType<object>(assocPath(['a.b.c'])(anyValue)(someObj));
|
|
expectType<object>(assocPath(['a.b.c'], anyValue)(someObj));
|
|
|
|
expectType<object>(assocPath(['a.b.c', 2, Symbol('hep')], anyValue, someObj));
|
|
expectType<object>(assocPath(['a.b.c', 2, Symbol('hep')])(anyValue, someObj));
|
|
expectType<object>(assocPath(['a.b.c', 2, Symbol('hep')])(anyValue)(someObj));
|
|
expectType<object>(assocPath(['a.b.c', 2, Symbol('hep')], 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'])(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));
|