From df7b8d7fc6d45f8aaca0df011a10fde130105b81 Mon Sep 17 00:00:00 2001 From: Alex Layton Date: Tue, 21 Apr 2020 15:11:34 -0400 Subject: [PATCH] Add TypeScript type definitions --- src/index.d.ts | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 src/index.d.ts diff --git a/src/index.d.ts b/src/index.d.ts new file mode 100755 index 0000000..53e861c --- /dev/null +++ b/src/index.d.ts @@ -0,0 +1,48 @@ +type notUndefined = boolean | number | string | object | null | notUndefined[] +export type Resolver = ( + values: Schema[], + path: string[], + mergeSchemas: (schemas: Schema[]) => Schema, + options: MergerOptions +) => notUndefined + +type PropertiesMerger = { + properties: Resolver + patternProperties: Resolver + additionalProperties: Resolver +} +type ItemsMerger = { + items: Resolver + additionalItems: Resolver +} +export type CombinedResolver = ( + values: Schema[], + path: string[], + mergers: Mergers, + options: MergerOptions +) => notUndefined +export interface Resolvers { + [key: string]: Resolver + properties?: CombinedResolver + items?: CombinedResolver + defaultResolver?: Resolver +} + +export interface MergerOptions { + /** + * @default false + */ + ignoreAdditionalProperties?: boolean + resolvers?: Resolvers + /** + * @default true + */ + deep?: boolean +} + +declare function merger ( + rootSchema: Schema, + options?: MergerOptions +): Schema + +export = merger