Skip to content

Commit

Permalink
feat: fix ts
Browse files Browse the repository at this point in the history
  • Loading branch information
0529bill committed Aug 4, 2022
1 parent cf9bbc0 commit 31498c5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
22 changes: 22 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -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)[]
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"validation"
],
"files": [
"dist"
"dist",
"index.d.ts"
],
"author": "water-tw",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit 31498c5

Please sign in to comment.