1

add initial types

This commit is contained in:
Conduitry 2022-08-09 01:14:47 -04:00
parent 0330ad5e12
commit 6cbc2346c4
2 changed files with 24 additions and 1 deletions

View File

@ -5,7 +5,15 @@
"private": true,
"homepage": "https://git.chor.date/Conduitry/svelte-tiny-validator",
"type": "module",
"types": "./validator.d.ts",
"main": "./validator.js",
"exports": {
".": "./validator.js"
".": {
"types": "./validator.d.ts",
"import": "./validator.js"
}
},
"peerDependencies": {
"svelte": "^3.46.6"
}
}

15
validator.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
import { Action } from 'svelte/action';
import { Writable } from 'svelte/store';
type Falsy = false | 0 | '' | null | undefined;
type Validator<T> = Action &
Writable<T | Falsy> & {
validate: (display?: boolean) => boolean;
};
export function validator<T = string>(chill?: boolean): Validator<T>;
export function validate(...validators: (Validator<any> | Falsy)[]): boolean;
export function reset(...validators: (Validator<any> | Falsy)[]): boolean;