UNPKG

@itrocks/property-type

Version:

Runtime type reflection from TypeScript declaration files for properties

49 lines (48 loc) 1.86 kB
import { Type } from '@itrocks/class-type'; type LiteralValue = boolean | number | null | string | undefined; export type Canonical = BigInt | Boolean | Number | Object | String | Symbol | undefined; export declare class PropertyType { type: Canonical; optional: boolean; constructor(type: Canonical, optional?: boolean); get lead(): Canonical; } export declare class CanonicalType extends PropertyType { constructor(type: Canonical); } export declare class CollectionType extends PropertyType { elementType: PropertyType; constructor(type: Type, elementType: PropertyType); } export declare class CompositeType extends PropertyType { types: PropertyType[]; constructor(types: PropertyType[]); get lead(): Canonical; } export declare class RecordType extends PropertyType { keyType: PropertyType; elementType: PropertyType; constructor(keyType: PropertyType, elementType: PropertyType); } export declare class IntersectionType extends CompositeType { } export declare class LiteralType extends PropertyType { value: LiteralValue; constructor(value: LiteralValue); } export declare class TypeType extends PropertyType { args?: PropertyType[] | undefined; constructor(type: Type, args?: PropertyType[] | undefined); } export declare class UnionType extends CompositeType { } export declare class UnknownType extends PropertyType { raw: string; constructor(raw: string); } export type PropertyTypes = Record<string, PropertyType>; export declare function isCanonical(propertyType: PropertyType, type?: Canonical): boolean; export declare function isLiteral(propertyType: PropertyType, literal?: LiteralValue): boolean; export declare function isType(propertyType: PropertyType, type?: Type): boolean; export declare function propertyTypesFromFile(file: string): PropertyTypes; export {};