vue-types
- Version 6.0.0
- Published
- 228 kB
- No dependencies
- MIT license
Install
npm i vue-types
yarn add vue-types
pnpm add vue-types
Overview
Prop types utility for Vue
Index
Variables
Functions
Classes
Interfaces
Type Aliases
Variables
variable config
const config: VueTypesConfig;
variable VueTypes_base
const VueTypes_base: { new (): {}; defaults: Partial<VueTypesDefaults>; sensibleDefaults: boolean | Partial<VueTypesDefaults>; config: VueTypesConfig; readonly any: VueTypeValidableDef<any, ValidatorFunction<any>>; readonly func: VueTypeValidableDef< (...args: any[]) => any, ValidatorFunction<(...args: any[]) => any> > & { default: (...args: any[]) => any }; readonly bool: VueTypeValidableDef<boolean, ValidatorFunction<boolean>>; readonly string: VueTypeValidableDef<string, ValidatorFunction<string>> & { default: string; }; readonly number: VueTypeValidableDef<number, ValidatorFunction<number>> & { default: number; }; readonly array: VueTypeValidableDef<unknown[], ValidatorFunction<unknown[]>> & { default: () => unknown[]; }; readonly object: VueTypeValidableDef< Record<string, any>, ValidatorFunction<Record<string, any>> > & { default: () => Record<string, any> }; readonly integer: VueTypeDef<number> & { default: number }; readonly symbol: VueTypeDef<symbol>; readonly nullable: PropOptions<null, null>; readonly custom: typeof custom; readonly oneOf: typeof oneOf; readonly instanceOf: typeof instanceOf; readonly oneOfType: typeof oneOfType; readonly arrayOf: typeof arrayOf; readonly objectOf: typeof objectOf; readonly shape: typeof shape; extend(...args: any[]): void; utils: { validate<T, U>(value: T, type: U): boolean; toType<T = unknown, Validable extends boolean = false>( name: string, obj: PropOptions<T, T>, validable?: Validable ): Validable extends true ? VueTypeValidableDef<T, ValidatorFunction<T>> : VueTypeDef<T>; };};
Functions
function any
any: <T = any>() => VueTypeValidableDef<T, ValidatorFunction<T>>;
function array
array: <T>() => VueTypeValidableDef<T[], ValidatorFunction<T[]>>;
function arrayOf
arrayOf: <T extends unknown>(type: T) => VueTypeDef<InferType<T>[]>;
function bool
bool: () => VueTypeValidableDef<boolean, ValidatorFunction<boolean>>;
function createTypes
createTypes: (defs?: Partial<VueTypesDefaults>) => { new (): {}; defaults: Partial<VueTypesDefaults>; sensibleDefaults: boolean | Partial<VueTypesDefaults>; config: VueTypesConfig; readonly any: VueTypeValidableDef<any, ValidatorFunction<any>>; readonly func: VueTypeValidableDef< (...args: any[]) => any, ValidatorFunction<(...args: any[]) => any> > & { default: (...args: any[]) => any }; readonly bool: VueTypeValidableDef<boolean, ValidatorFunction<boolean>>; readonly string: VueTypeValidableDef<string, ValidatorFunction<string>> & { default: string; }; readonly number: VueTypeValidableDef<number, ValidatorFunction<number>> & { default: number; }; readonly array: VueTypeValidableDef<unknown[], ValidatorFunction<unknown[]>> & { default: () => unknown[]; }; readonly object: VueTypeValidableDef< Record<string, any>, ValidatorFunction<Record<string, any>> > & { default: () => Record<string, any> }; readonly integer: VueTypeDef<number> & { default: number }; readonly symbol: VueTypeDef<symbol>; readonly nullable: PropOptions<null, null>; readonly custom: typeof custom; readonly oneOf: typeof oneOf; readonly instanceOf: typeof instanceOf; readonly oneOfType: typeof oneOfType; readonly arrayOf: typeof arrayOf; readonly objectOf: typeof objectOf; readonly shape: typeof shape; extend(...args: any[]): void; utils: { validate<T, U>(value: T, type: U): boolean; toType<T = unknown, Validable extends boolean = false>( name: string, obj: PropOptions<T, T>, validable?: Validable ): Validable extends true ? VueTypeValidableDef<T, ValidatorFunction<T>> : VueTypeDef<T>; };};
function custom
custom: <T>( validatorFn: ValidatorFunction<T>, warnMsg?: string) => VueTypeDef<T>;
function fromType
fromType: { <T extends VueTypeDef<any>>(name: string, source: T): T; <T extends VueTypeDef<any>, V extends PropOptions<InferType<T>, InferType<T>>>( name: string, source: T, props: V ): Omit<T, keyof V> & V;};
Return a new VueTypes type using another type as base.
Properties in the
props
object will overwrite those defined in the source one expect for thevalidator
function. In that case both functions will be executed in series.Parameter name
Name of the new type
Parameter source
Source type
Parameter props
Custom type properties
function func
func: <T extends (...args: any[]) => any>() => VueTypeValidableDef< T, ValidatorFunction<T>>;
function instanceOf
instanceOf: <C extends Constructor>( instanceConstructor: C) => VueTypeDef<InstanceType<C>>;
function integer
integer: <T extends number = number>() => VueTypeDef<T>;
function nullable
nullable: () => PropOptions<null>;
function number
number: <T extends number = number>() => VueTypeValidableDef< T, ValidatorFunction<T>>;
function object
object: <T extends Record<string, any>>() => VueTypeValidableDef< T, ValidatorFunction<T>>;
function objectOf
objectOf: <T extends unknown>( type: T) => VueTypeDef<Record<string, InferType<T>>>;
function oneOf
oneOf: <D, T extends readonly D[] = readonly D[]>( arr: T) => VueTypeDef<T[number]>;
function oneOfType
oneOfType: <D extends V, U extends unknown = any, V = InferType<U>>( arr: U[]) => VueTypeDef<D>;
function shape
shape: <T extends object>(obj: { [K in keyof T]: any }) => VueTypeShape<T>;
function string
string: <T extends string = string>() => VueTypeValidableDef< T, ValidatorFunction<T>>;
function symbol
symbol: () => VueTypeDef<symbol>;
function toType
toType: <T = any>(name: string, obj: PropOptions<T>) => VueTypeDef<T>;
Adds
isRequired
anddef
modifiers to an objectParameter name
Type internal name
Parameter obj
Object to enhance
function toValidableType
toValidableType: <T = any>( name: string, obj: PropOptions<T>) => VueTypeValidableDef<T>;
Like
toType
but also adds thevalidate()
method to the type objectParameter name
Type internal name
Parameter obj
Object to enhance
function validateType
validateType: <T, U>(type: T, value: U, silent?: boolean) => string | boolean;
Validates a given value against a prop type object.
If
silent
isfalse
(default) will return a boolean. If it is set totrue
it will returntrue
on success or a string error message on failureParameter type
Type to use for validation. Either a type object or a constructor
Parameter value
Value to check
Parameter silent
Silence warnings
Classes
class VueTypes
class VueTypes extends VueTypes_base {}
Interfaces
interface VueTypeLooseShape
interface VueTypeLooseShape<T> extends VueTypeBaseDef< T, DefaultFactory<Partial<T & Record<string, any>>>, () => Partial<T> & Record<string, any> > {}
property loose
readonly loose: VueTypeLooseShape<T>;
interface VueTypeShape
interface VueTypeShape<T> extends VueTypeBaseDef<T, DefaultType<Partial<T>>, () => Partial<T>> {}
property loose
readonly loose: VueTypeLooseShape<T>;
interface VueTypeValidableDef
interface VueTypeValidableDef<T = unknown, V = ValidatorFunction<T>> extends VueTypeBaseDef<T> {}
property validate
readonly validate: (fn: V) => this & { validator: V };
Type Aliases
type VueTypeDef
type VueTypeDef<T = unknown> = VueTypeBaseDef<T>;
type VueTypesInterface
type VueTypesInterface = ReturnType<typeof createTypes>;
Package Files (2)
Dependencies (0)
No dependencies.
Dev Dependencies (3)
Peer Dependencies (1)
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/vue-types
.
- Markdown[](https://www.jsdocs.io/package/vue-types)
- HTML<a href="https://www.jsdocs.io/package/vue-types"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 4057 ms. - Missing or incorrect documentation? Open an issue for this package.