Interface IProps<Target, Kind, Value, Validate, Exclusive, Schema>

interface IProps<
    Target extends
        "boolean"
        | "bigint"
        | "number"
        | "string"
        | "array"
        | "object",
    Kind extends string,
    Value extends boolean | bigint | number | string | undefined,
    Validate extends string | { [key in Target]?: string },
    Exclusive extends boolean | string[],
    Schema extends object | undefined,
> {
    exclusive?: Exclusive | string[];
    kind: Kind;
    schema?: Schema;
    target: Target;
    validate?: Validate;
    value: Value;
}

Type Parameters

  • Target extends "boolean" | "bigint" | "number" | "string" | "array" | "object"
  • Kind extends string
  • Value extends boolean | bigint | number | string | undefined
  • Validate extends string | { [key in Target]?: string }
  • Exclusive extends boolean | string[]
  • Schema extends object | undefined

Properties

exclusive?: Exclusive | string[]

Exclusive option.

If this property configured as true, same kind tag cannot be duplicated in the target type. Otherwise, if you've configured this property as string array, all of the kind value assigned tags cannot be compatible in the target type.

false
kind: Kind

What kind of tag is this?

schema?: Schema

Additional schema info assigned to the IJsonSchema object.

target: Target

Target type.

If user tries to adapt this tag to a different type, it would be a compile error.

For example, you've configured target type as string, but user adapted it onto a number type (number & YourCustomTag<Value>), then it would be blocked by TypeScript compiler.

validate?: Validate

Validation script.

This script would be inserted into the generated validation function. In here script, target variable name must be $input. The variable name $input would be transformed to the suitable when compilation.

Also, If you've take a mistake on this script, compile error would be occured. So, define it with confidence. Compiler will block all your mistakes.

value: Value

Value to be configured by user.