From 31498c508b449dfcbbe47a82f2b0332b24ebbb25 Mon Sep 17 00:00:00 2001 From: bill <0529bilL@gmail.com> Date: Thu, 4 Aug 2022 15:23:38 +0800 Subject: [PATCH] feat: fix ts --- index.d.ts | 22 ++++++++++++++++++++++ package.json | 3 ++- tsconfig.json | 4 ++-- 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..18f831d --- /dev/null +++ b/index.d.ts @@ -0,0 +1,22 @@ +export interface ErrorObject { + index: string + condition: (string | number | boolean | undefined | null)[] + errorMessage?: string + customCondition?: (dataSource: unknown, conditionReturnArray: boolean[]) => boolean[] + errorFormat?: string[] +} +export declare type ErrorResult = { + msg: string +} +export declare type ErrorValidation = { + [key: string | number]: ErrorResult | '' | string | null | (string | ErrorResult | null)[] +} +export declare const handleValidation: ({ + errorArray, + dataSource, + defaultErrorMessage, +}: { + errorArray: ErrorObject[] + dataSource?: unknown + defaultErrorMessage?: string | undefined +}) => (boolean | ErrorValidation)[] diff --git a/package.json b/package.json index f12c918..a53343b 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,8 @@ "validation" ], "files": [ - "dist" + "dist", + "index.d.ts" ], "author": "water-tw", "license": "MIT", diff --git a/tsconfig.json b/tsconfig.json index a16bf87..03b574b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -47,8 +47,8 @@ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ /* Emit */ - "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, - "declarationDir": ".", + // "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, + // "declarationDir": ".", // "declarationMap": true, /* Create sourcemaps for d.ts files. */ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */