ts-ref-kit 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/package.json +8 -12
  2. package/types/index.d.ts +2 -0
  3. package/types/parser/index.d.ts +3 -0
  4. package/types/parser/path-match.d.ts +7 -0
  5. package/types/parser/reflect-loader.d.ts +10 -0
  6. package/types/parser/reflect-parser-plugin.d.ts +7 -0
  7. package/{dist/types/parser/index.d.ts → types/parser/reflect-parser.d.ts} +77 -110
  8. package/types/reflect-json/Mappable.d.ts +13 -0
  9. package/types/reflect-json/decorate.d.ts +18 -0
  10. package/types/reflect-json/index.d.ts +6 -0
  11. package/types/reflect-json/json-translation.d.ts +38 -0
  12. package/types/reflect-json/reflect-extension.d.ts +13 -0
  13. package/types/reflect-json/types.d.ts +15 -0
  14. package/types/reflect-json/utils.d.ts +9 -0
  15. package/types/reflect-types/ClassDefinition.d.ts +28 -0
  16. package/types/reflect-types/EnumDefinition.d.ts +8 -0
  17. package/types/reflect-types/InterfaceDefinition.d.ts +18 -0
  18. package/types/reflect-types/MethodDefinition.d.ts +15 -0
  19. package/types/reflect-types/PropertyDefinition.d.ts +18 -0
  20. package/types/reflect-types/assert-type.d.ts +14 -0
  21. package/types/reflect-types/function-validate.d.ts +10 -0
  22. package/types/reflect-types/index.d.ts +11 -0
  23. package/types/reflect-types/package.d.ts +10 -0
  24. package/types/reflect-types/reflect-context.d.ts +16 -0
  25. package/types/reflect-types/reflect-definitions.d.ts +104 -0
  26. package/types/reflect-types/reflect-types.d.ts +20 -0
  27. package/types/reflect-types/reflect-validate.d.ts +24 -0
  28. package/dist/types/index.d.ts +0 -455
  29. package/dist/types/tsdoc-metadata.json +0 -11
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-ref-kit",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
4
4
  "description": "Type reflection and validation library for TypeScript",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -14,36 +14,32 @@
14
14
  ],
15
15
  "exports": {
16
16
  ".": {
17
- "types": "./dist/types/index.d.ts",
17
+ "types": "./types/index.d.ts",
18
18
  "import": "./dist/esm/index.js",
19
19
  "require": "./dist/cjs/index.cjs"
20
20
  },
21
21
  "./parser": {
22
- "types": "./dist/types/parser/index.d.ts",
22
+ "types": "./types/parser/index.d.ts",
23
23
  "import": "./dist/esm/parser/index.js",
24
24
  "require": "./dist/cjs/parser/index.cjs"
25
25
  }
26
26
  },
27
27
  "typesVersions": {
28
28
  "*": {
29
- "parser": [
30
- "types/parser/index.d.ts"
31
- ],
32
- "*": [
33
- "types/index.d.ts"
34
- ]
29
+ "parser": ["types/parser/index.d.ts"],
30
+ "*": ["types/index.d.ts"]
35
31
  }
36
32
  },
37
33
  "scripts": {
38
- "clean": "rimraf dist types",
39
- "build": "npm run clean && node esbuild.config.js && node esbuild.parser.config.js && tsc --emitDeclarationOnly && api-extractor run --local --config api-extractor.json && api-extractor run --local --config api-extractor.parser.json && rimraf types"
34
+ "build-types": "tsc --emitDeclarationOnly --outDir types",
35
+ "clean": "rm -rf dist types",
36
+ "build": "npm run clean && node esbuild.config.js && node esbuild.parser.config.js && tsc --emitDeclarationOnly --outDir types"
40
37
  },
41
38
  "dependencies": {
42
39
  "reflect-metadata": "^0.2.2",
43
40
  "tslib": "^2.8.1"
44
41
  },
45
42
  "devDependencies": {
46
- "@microsoft/api-extractor": "^7.52.11",
47
43
  "@types/node": "^24.2.0",
48
44
  "esbuild": "^0.25.9",
49
45
  "rimraf": "^6.0.1",
@@ -0,0 +1,2 @@
1
+ export * from './reflect-types';
2
+ export * from './reflect-json';
@@ -0,0 +1,3 @@
1
+ export * from './reflect-loader';
2
+ export * from './reflect-parser-plugin';
3
+ export * from './reflect-parser';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * 检查文件路径是否匹配 glob 规则
3
+ * @param filePath 要检查的文件路径(绝对或相对路径)
4
+ * @param pattern glob 规则,如 `/src/**\/.ts`
5
+ * @returns 是否匹配
6
+ */
7
+ export default function isPathMatch(filePath: string, pattern: string | string[]): boolean;
@@ -0,0 +1,10 @@
1
+ export interface ReflectLoaderOptions {
2
+ sourcePaths: string | string[];
3
+ exclude?: string | RegExp | (string | RegExp)[];
4
+ forEnabledClassOnly?: boolean;
5
+ outputLog?: boolean;
6
+ }
7
+ export declare function reflectLoader(options: ReflectLoaderOptions): {
8
+ outputAllMetas: () => string;
9
+ transform: (sourceCode: string, sourceFileName: string) => string;
10
+ };
@@ -0,0 +1,7 @@
1
+ import { type Plugin } from 'vite';
2
+ import { ReflectLoaderOptions } from './reflect-loader';
3
+ interface Options extends ReflectLoaderOptions {
4
+ entry: string;
5
+ }
6
+ export declare function reflectParserPlugin(options: Options): Plugin;
7
+ export {};
@@ -1,110 +1,77 @@
1
- import { Plugin as Plugin_2 } from 'vite';
2
-
3
- declare type Any = any;
4
-
5
- export declare const DEBUG_CONFIG: {
6
- OUTPUT_LOG: boolean;
7
- };
8
-
9
- declare type FilePathRule = string | RegExp | (string | RegExp)[];
10
-
11
- declare interface Options extends ReflectLoaderOptions {
12
- entry: string;
13
- }
14
-
15
- export declare function parseSource(filePaths?: string | string[], exclude?: FilePathRule): {
16
- classDefinitions: Map<string, RawClassDefinition>;
17
- interfaceDefinitions: Map<string, RawInterfaceDefinition>;
18
- enumDefinitions: Map<string, RawEnumDefinition>;
19
- typeAliasDefinitions: Map<string, RawTypeDef>;
20
- constTypeDefinitions: Map<string, RawTypeDef>;
21
- };
22
-
23
- export declare interface RawClassDefinition {
24
- name: string;
25
- superClassName?: string;
26
- implementations?: string[];
27
- methods?: RawMethodDefinition[];
28
- properties?: RawPropertyDefinition[];
29
- }
30
-
31
- export declare interface RawEnumDefinition {
32
- name: string;
33
- members: {
34
- name: string;
35
- initializer: string | undefined;
36
- }[];
37
- }
38
-
39
- export declare interface RawInterfaceDefinition {
40
- name: string;
41
- implementations?: string[];
42
- methods?: RawMethodDefinition[];
43
- properties?: RawPropertyDefinition[];
44
- indexElementType?: RawTypeDef;
45
- }
46
-
47
- export declare interface RawMethodDefinition {
48
- name: string;
49
- isPrivate?: boolean;
50
- isStatic?: boolean;
51
- isAsync?: boolean;
52
- returnType?: RawTypeDef;
53
- args?: {
54
- name: string;
55
- type?: RawTypeDef;
56
- isOptional: boolean;
57
- }[];
58
- }
59
-
60
- export declare interface RawPropertyDefinition {
61
- name: string;
62
- isOptional?: boolean;
63
- isPrivate?: boolean;
64
- isStatic?: boolean;
65
- type?: RawTypeDef;
66
- accessor?: {
67
- getter?: {
68
- isPrivate: boolean;
69
- };
70
- setter?: {
71
- isPrivate: boolean;
72
- };
73
- };
74
- }
75
-
76
- declare type RawTypeDef = string | RawTypeDefinition;
77
-
78
- export declare interface RawTypeDefinition {
79
- arrayElementType?: RawTypeDef;
80
- indexElementType?: RawTypeDef;
81
- literalValue?: Any;
82
- typeLiteralMembers?: RawPropertyDefinition[];
83
- unionMembers?: RawTypeDef[];
84
- intersectionMembers?: RawTypeDef[];
85
- generics?: RawTypeDef[];
86
- isFunction?: boolean;
87
- tupleMembers?: RawTypeDef[];
88
- isOptionalInTuple?: boolean;
89
- isConstructor?: boolean;
90
- }
91
-
92
- export declare function reflectLoader(options: ReflectLoaderOptions): {
93
- outputAllMetas: () => string;
94
- transform: (sourceCode: string, sourceFileName: string) => string;
95
- };
96
-
97
- export declare interface ReflectLoaderOptions {
98
- sourcePaths: string | string[];
99
- exclude?: string | RegExp | (string | RegExp)[];
100
- forEnabledClassOnly?: boolean;
101
- outputLog?: boolean;
102
- }
103
-
104
- export declare function reflectParserPlugin(options: Options): Plugin_2;
105
-
106
- export declare function setupReflectTypes(filePaths: string | string[], exclude?: FilePathRule, distFolder?: string): Promise<void>;
107
-
108
- export declare function updateReflectModules(filePath: string, distFolder: string): Promise<void>;
109
-
110
- export { }
1
+ export declare const DEBUG_CONFIG: {
2
+ OUTPUT_LOG: boolean;
3
+ };
4
+ type Any = any;
5
+ export interface RawClassDefinition {
6
+ name: string;
7
+ superClassName?: string;
8
+ implementations?: string[];
9
+ methods?: RawMethodDefinition[];
10
+ properties?: RawPropertyDefinition[];
11
+ }
12
+ export interface RawInterfaceDefinition {
13
+ name: string;
14
+ implementations?: string[];
15
+ methods?: RawMethodDefinition[];
16
+ properties?: RawPropertyDefinition[];
17
+ indexElementType?: RawTypeDef;
18
+ }
19
+ export interface RawEnumDefinition {
20
+ name: string;
21
+ members: {
22
+ name: string;
23
+ initializer: string | undefined;
24
+ }[];
25
+ }
26
+ export interface RawMethodDefinition {
27
+ name: string;
28
+ isPrivate?: boolean;
29
+ isStatic?: boolean;
30
+ isAsync?: boolean;
31
+ returnType?: RawTypeDef;
32
+ args?: {
33
+ name: string;
34
+ type?: RawTypeDef;
35
+ isOptional: boolean;
36
+ }[];
37
+ }
38
+ export interface RawPropertyDefinition {
39
+ name: string;
40
+ isOptional?: boolean;
41
+ isPrivate?: boolean;
42
+ isStatic?: boolean;
43
+ type?: RawTypeDef;
44
+ accessor?: {
45
+ getter?: {
46
+ isPrivate: boolean;
47
+ };
48
+ setter?: {
49
+ isPrivate: boolean;
50
+ };
51
+ };
52
+ }
53
+ type RawTypeDef = string | RawTypeDefinition;
54
+ export interface RawTypeDefinition {
55
+ arrayElementType?: RawTypeDef;
56
+ indexElementType?: RawTypeDef;
57
+ literalValue?: Any;
58
+ typeLiteralMembers?: RawPropertyDefinition[];
59
+ unionMembers?: RawTypeDef[];
60
+ intersectionMembers?: RawTypeDef[];
61
+ generics?: RawTypeDef[];
62
+ isFunction?: boolean;
63
+ tupleMembers?: RawTypeDef[];
64
+ isOptionalInTuple?: boolean;
65
+ isConstructor?: boolean;
66
+ }
67
+ type FilePathRule = string | RegExp | (string | RegExp)[];
68
+ export declare function setupReflectTypes(filePaths: string | string[], exclude?: FilePathRule, distFolder?: string): Promise<void>;
69
+ export declare function updateReflectModules(filePath: string, distFolder: string): Promise<void>;
70
+ export declare function parseSource(filePaths?: string | string[], exclude?: FilePathRule): {
71
+ classDefinitions: Map<string, RawClassDefinition>;
72
+ interfaceDefinitions: Map<string, RawInterfaceDefinition>;
73
+ enumDefinitions: Map<string, RawEnumDefinition>;
74
+ typeAliasDefinitions: Map<string, RawTypeDef>;
75
+ constTypeDefinitions: Map<string, RawTypeDef>;
76
+ };
77
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type EnableReflect } from '../reflect-types';
2
+ import type { Class, JsonValue } from './types';
3
+ export interface Mappable extends EnableReflect {
4
+ mapping(map: Mapping<Mappable>): void;
5
+ }
6
+ export type Mapping<T extends Mappable> = {
7
+ [propName in keyof T]-?: (fieldName?: string | symbol, transform?: {
8
+ fromJSON?: (jsonValue: JsonValue) => Mappable;
9
+ toJSON?: (obj: Mappable) => JsonValue;
10
+ }) => void;
11
+ };
12
+ export declare function registerMappable<T extends Mappable>(mappableClass: Class<T>): void;
13
+ export declare function mapAllProperties<T extends Mappable>(target: T, map: Mapping<T>): void;
@@ -0,0 +1,18 @@
1
+ import { ReflectPropertyKey } from './reflect-extension';
2
+ import type { Any } from './types';
3
+ export declare function defineDecoratedProperty(metaKey: symbol): PropertyDecorator;
4
+ export declare function callDecoratedMethod<Self extends object>(self: Self, metaKey: symbol, ...args: Any[]): Any | undefined;
5
+ export declare function hasDecoratedMethod<Self extends object>(self: Self, metaKey: symbol): boolean;
6
+ export declare function getDecoratedProperty(target: object, metaKey: symbol): ReflectPropertyKey | undefined;
7
+ export declare function getDecoratedPropertyValue<V>(target: object, metaKey: symbol): V | undefined;
8
+ export declare const PropertyWrapper: IPropertyWrapper;
9
+ type IPropertyWrapper = {
10
+ getField: (owner: object, property: ReflectPropertyKey, fieldSymbol: symbol) => Any;
11
+ setField: (owner: object, property: ReflectPropertyKey, newValue: Any, fieldSymbol: symbol) => void;
12
+ } & (<T>({ getter, setter, fieldSymbol }: {
13
+ getter?: (self: object, property: ReflectPropertyKey) => T;
14
+ setter?: (self: object, newValue: T, property: ReflectPropertyKey) => void;
15
+ fieldSymbol: symbol;
16
+ }) => PropertyDecorator);
17
+ export declare function Lazy(creator: (self: object, property: ReflectPropertyKey) => Any): PropertyDecorator;
18
+ export {};
@@ -0,0 +1,6 @@
1
+ export * from './Mappable';
2
+ export * from './decorate';
3
+ export * from './json-translation';
4
+ export * from './reflect-extension';
5
+ export * from './types';
6
+ export * from './utils';
@@ -0,0 +1,38 @@
1
+ import 'reflect-metadata';
2
+ import { Any, AnyObject, Class, ClassOrInstance, JsonObject, JsonValue } from './types';
3
+ type FromJSON<T> = (jsonValue: JsonValue) => T;
4
+ type ToJSON<T> = (obj: T) => JsonValue;
5
+ type SerializedOptions<T> = {
6
+ name?: string;
7
+ class?: Class<T>;
8
+ fromJSON?: FromJSON<T>;
9
+ toJSON?: ToJSON<T>;
10
+ };
11
+ export declare function setDefaultIgnored(clazz: Class<Any>, defaultIgnored: boolean): void;
12
+ export declare function registerSerializedProperty(target: AnyObject, propName: string, options: SerializedOptions<Any>): void;
13
+ export declare const SerializedClass: PropertyDecorator;
14
+ export declare function Serialized<T extends object>(options?: SerializedOptions<T>): PropertyDecorator;
15
+ export declare function SerializedName(serializedName: string): PropertyDecorator;
16
+ export declare const IgnoreSerialization: PropertyDecorator;
17
+ /**
18
+ * serialize an object to json string
19
+ */
20
+ export declare function serialize<T>(value: T): string;
21
+ export declare function serializeTo<T>(value: T): JsonValue;
22
+ /**
23
+ * convert an object to data object
24
+ */
25
+ export declare function serializeToData<T extends object>(object: T): JsonObject | JsonObject[];
26
+ export declare function deserialize<T>(json: string | JsonValue, constructorOrTarget?: ClassOrInstance<T>): T;
27
+ export declare function deserializeArray<T>(json: string | JsonValue[], clazz?: Class<T>): T[];
28
+ export declare function deserializeFrom<T extends AnyObject>(data: JsonObject, target: T): void;
29
+ export declare function getSerializeSettings(clazz: Class<Any>): any;
30
+ export interface JsonValueTransform<T> {
31
+ fromJson: FromJSON<T>;
32
+ toJson: ToJSON<T>;
33
+ }
34
+ export declare function registerTransform<T>(clazz: Class<T>, transform: JsonValueTransform<T>): void;
35
+ export declare const itSelf: (some: Any) => any;
36
+ export declare const done: () => any;
37
+ export declare const AfterSerialized: PropertyDecorator;
38
+ export {};
@@ -0,0 +1,13 @@
1
+ import 'reflect-metadata';
2
+ import { Any, AnyConstructorFunction, AnyObject, Optional } from './types';
3
+ export type ReflectPropertyKey = string | symbol;
4
+ export type ReflectType = StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor | FunctionConstructor | AnyConstructorFunction;
5
+ declare global {
6
+ namespace Reflect {
7
+ function getDesignType<T extends AnyObject>(target: T, property: keyof T | ReflectPropertyKey): Optional<ReflectType>;
8
+ function getReturnType<T extends AnyObject>(target: T, property: keyof T | ReflectPropertyKey): Optional<ReflectType>;
9
+ function getParamTypes<T extends AnyObject>(target: T, property: keyof T | ReflectPropertyKey): Optional<ReflectType[]>;
10
+ function addMetadataList<T extends object>(key: symbol, value: Any, target: T): void;
11
+ function addMetadataList<T extends object>(key: symbol, value: Any, target: T, property: ReflectPropertyKey): void;
12
+ }
13
+ }
@@ -0,0 +1,15 @@
1
+ export type Any = any;
2
+ export type AnyFunction = (...args: Any[]) => Any;
3
+ export type AnyConstructorFunction = new (...args: Any[]) => Any;
4
+ export type Class<T> = new (...args: Any[]) => T;
5
+ export type ClassOrInstance<T> = T | Class<T>;
6
+ export type Dictionary<T> = {
7
+ [key: string | symbol]: T;
8
+ };
9
+ export type AnyObject = Dictionary<Any>;
10
+ export type Optional<T> = T | undefined;
11
+ export type Nullable<T> = T | null;
12
+ export type JsonValue = string | number | boolean | null | JsonObject | JsonObject[];
13
+ export type JsonObject = {
14
+ [propName: string]: JsonValue;
15
+ };
@@ -0,0 +1,9 @@
1
+ import { Any, Class } from "./types";
2
+ export declare function asBoolean(value: unknown): boolean;
3
+ export declare function asString(v: unknown): string;
4
+ export declare function asNumber(v: unknown): number;
5
+ export declare function setAnyValue<T>(target: Any, field: string | number | symbol, value: T): void;
6
+ export declare function getAnyValue<T>(target: Any, field: string | number | symbol): T | undefined;
7
+ export declare function getOrSetValue<T>(target: Any, field: string | number | symbol, defaultWith: () => T): T;
8
+ export declare function isDictionary(value: Any): boolean;
9
+ export declare function createNewInstance<T>(clazz: Class<T>): any;
@@ -0,0 +1,28 @@
1
+ import { RawClassDefinition, TypeDefinition } from './index';
2
+ import { InterfaceDefinition, MethodDefinition, PropertyDefinition } from './index';
3
+ import type { AnyConstructorFunction, Dictionary } from './package';
4
+ type ImplementationOfClass = InterfaceDefinition | TypeDefinition;
5
+ export declare class ClassDefinition {
6
+ readonly name: string;
7
+ readonly superClassName: string;
8
+ readonly superClass: ClassDefinition | undefined;
9
+ readonly methods: MethodDefinition[];
10
+ readonly properties: PropertyDefinition[];
11
+ readonly jsClass: AnyConstructorFunction;
12
+ private readonly _implementationNames;
13
+ private readonly _implementations?;
14
+ private _allImplementations?;
15
+ constructor(def: RawClassDefinition & {
16
+ jsClass: AnyConstructorFunction;
17
+ });
18
+ get allMethods(): Dictionary<MethodDefinition>;
19
+ get allProperties(): Dictionary<PropertyDefinition>;
20
+ get implementations(): ImplementationOfClass[];
21
+ get allImplementations(): ImplementationOfClass[];
22
+ getProperty(propName: string): PropertyDefinition | undefined;
23
+ get type(): TypeDefinition;
24
+ isSubClassOf(typeName: string): boolean;
25
+ isSuperClassOf(typeName: string): boolean;
26
+ toString(): string;
27
+ }
28
+ export {};
@@ -0,0 +1,8 @@
1
+ import type { RawEnumDefinition, TypeDefinition } from './reflect-definitions';
2
+ export declare class EnumDefinition {
3
+ readonly name: string;
4
+ readonly members: Map<string, TypeDefinition>;
5
+ constructor(def: RawEnumDefinition);
6
+ get type(): TypeDefinition;
7
+ get names(): string[];
8
+ }
@@ -0,0 +1,18 @@
1
+ import { ClassDefinition, RawInterfaceDefinition, TypeDefinition } from './index';
2
+ import { MethodDefinition, PropertyDefinition } from './index';
3
+ type ImplementationOfInterface = InterfaceDefinition | ClassDefinition | TypeDefinition;
4
+ export declare class InterfaceDefinition {
5
+ readonly name: string;
6
+ readonly methods: MethodDefinition[];
7
+ readonly properties: PropertyDefinition[];
8
+ private readonly _implementationNames;
9
+ private _implementations?;
10
+ private _allImplementations?;
11
+ constructor(def: RawInterfaceDefinition);
12
+ get implementations(): ImplementationOfInterface[];
13
+ get allImplementations(): ImplementationOfInterface[];
14
+ get type(): TypeDefinition;
15
+ toString(): string;
16
+ buildBaseObject(): {};
17
+ }
18
+ export {};
@@ -0,0 +1,15 @@
1
+ import { type RawMethodDefinition, type TypeDefinition } from './index';
2
+ export declare class MethodDefinition {
3
+ name: string;
4
+ isPrivate: boolean;
5
+ isStatic: boolean;
6
+ isAsync: boolean;
7
+ returnType: TypeDefinition;
8
+ args: {
9
+ name: string;
10
+ type?: TypeDefinition;
11
+ isOptional: boolean;
12
+ }[];
13
+ constructor(def: RawMethodDefinition);
14
+ }
15
+ export declare function fillMethod(rawMethod: RawMethodDefinition): MethodDefinition;
@@ -0,0 +1,18 @@
1
+ import { type RawPropertyDefinition, type TypeDefinition } from './index';
2
+ export declare class PropertyDefinition {
3
+ name: string;
4
+ isOptional: boolean;
5
+ isPrivate: boolean;
6
+ isStatic: boolean;
7
+ type: TypeDefinition;
8
+ accessor?: {
9
+ getter?: {
10
+ isPrivate: boolean;
11
+ };
12
+ setter?: {
13
+ isPrivate: boolean;
14
+ };
15
+ };
16
+ constructor(def: RawPropertyDefinition);
17
+ }
18
+ export declare function fillProperty(rawProperty: RawPropertyDefinition): PropertyDefinition;
@@ -0,0 +1,14 @@
1
+ import { type TypeDefinition } from '.';
2
+ export type Type = string | {
3
+ array: Type;
4
+ } | {
5
+ union: Type[];
6
+ } | {
7
+ intersection: Type[];
8
+ } | {
9
+ tuple: Type[];
10
+ };
11
+ export declare function getTypeDef(type: Type | TypeDefinition): TypeDefinition;
12
+ export declare function assertType<T>(data: unknown, type: Type, depth?: number): T;
13
+ export declare function isNullable(type: Type | TypeDefinition): boolean;
14
+ export declare function isType(value: unknown, type: Type | TypeDefinition): boolean;
@@ -0,0 +1,10 @@
1
+ import { type AnyFunction } from './package';
2
+ declare const VALIDATE_WRAPPER: unique symbol;
3
+ declare global {
4
+ interface Function {
5
+ [VALIDATE_WRAPPER]: AnyFunction;
6
+ }
7
+ }
8
+ export declare const ReflectValidate: MethodDecorator;
9
+ export declare function safeCall(target: object, methodName: string, ...args: unknown[]): unknown;
10
+ export {};
@@ -0,0 +1,11 @@
1
+ export * from './reflect-definitions';
2
+ export * from './reflect-context';
3
+ export * from './ClassDefinition';
4
+ export * from './InterfaceDefinition';
5
+ export * from './EnumDefinition';
6
+ export * from './MethodDefinition';
7
+ export * from './PropertyDefinition';
8
+ export * from './reflect-types';
9
+ export * from './reflect-validate';
10
+ export * from './assert-type';
11
+ export * from './function-validate';
@@ -0,0 +1,10 @@
1
+ export type Dictionary<T> = {
2
+ [key: string]: T;
3
+ };
4
+ type Any = any;
5
+ export type AnyConstructorFunction = new (...args: Any[]) => Any;
6
+ export type AnyFunction = (...args: Any[]) => Any;
7
+ export declare function setValue<T>(target: unknown, field: string | symbol, value: T): void;
8
+ export declare function getValue<T>(target: unknown, field: string | symbol): T | undefined;
9
+ export declare function mapNotNull<T, U>(arr: T[] | undefined, mapper: (item: T) => U | undefined): U[];
10
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { AnyConstructorFunction } from './package';
2
+ import { type TypeDefinition } from './index';
3
+ import { ClassDefinition, EnumDefinition, InterfaceDefinition } from './index';
4
+ export declare const ReflectClass: ClassDecorator;
5
+ export declare const ReflectContext: {
6
+ getClassDefinition: typeof getClassDefinition;
7
+ getInterfaceDefinition: typeof getInterfaceDefinition;
8
+ getEnumDefinition: typeof getEnumDefinition;
9
+ getTypeAliasDefinition: typeof getTypeAliasDefinition;
10
+ };
11
+ export declare function getClassByName(className: string): AnyConstructorFunction | undefined;
12
+ declare function getClassDefinition(arg: AnyConstructorFunction | object | string): ClassDefinition | undefined;
13
+ declare function getInterfaceDefinition(name: string): InterfaceDefinition | undefined;
14
+ declare function getEnumDefinition(name: string): EnumDefinition | undefined;
15
+ declare function getTypeAliasDefinition(name: string): TypeDefinition | undefined;
16
+ export {};
@@ -0,0 +1,104 @@
1
+ import { ClassDefinition, PropertyDefinition } from './index';
2
+ export interface RawTypeDefinition {
3
+ arrayElementType?: RawTypeDef;
4
+ literalValue?: unknown;
5
+ typeLiteralMembers?: RawPropertyDefinition[];
6
+ unionMembers?: RawTypeDef[];
7
+ intersectionMembers?: RawTypeDef[];
8
+ isFunction?: boolean;
9
+ tupleMembers?: RawTypeDef[];
10
+ isOptionalInTuple?: boolean;
11
+ isConstructor?: boolean;
12
+ generics?: RawTypeDef[];
13
+ }
14
+ type RawTypeDef = string | RawTypeDefinition;
15
+ export interface RawClassDefinition {
16
+ name: string;
17
+ superClassName?: string;
18
+ implementations?: string[];
19
+ methods?: RawMethodDefinition[];
20
+ properties?: RawPropertyDefinition[];
21
+ }
22
+ export interface RawInterfaceDefinition {
23
+ name: string;
24
+ implementations?: string[];
25
+ methods?: RawMethodDefinition[];
26
+ properties?: RawPropertyDefinition[];
27
+ }
28
+ export interface RawEnumDefinition {
29
+ name: string;
30
+ members: {
31
+ name: string;
32
+ initializer: string | undefined;
33
+ }[];
34
+ }
35
+ export interface RawMethodDefinition {
36
+ name: string;
37
+ isPrivate?: boolean;
38
+ isStatic?: boolean;
39
+ isAsync?: boolean;
40
+ returnType?: RawTypeDef;
41
+ args?: {
42
+ name: string;
43
+ type?: RawTypeDef;
44
+ isOptional: boolean;
45
+ }[];
46
+ }
47
+ export interface RawPropertyDefinition {
48
+ name: string;
49
+ isOptional?: boolean;
50
+ isPrivate?: boolean;
51
+ isStatic?: boolean;
52
+ type?: RawTypeDef;
53
+ accessor?: {
54
+ getter?: {
55
+ isPrivate: boolean;
56
+ };
57
+ setter?: {
58
+ isPrivate: boolean;
59
+ };
60
+ };
61
+ }
62
+ export interface TypeDefinition {
63
+ name?: string;
64
+ arrayElementType?: TypeDefinition;
65
+ literalValue?: string;
66
+ typeLiteralMembers?: PropertyDefinition[];
67
+ unionMembers?: TypeDefinition[];
68
+ intersectionMembers?: TypeDefinition[];
69
+ isFunction?: boolean;
70
+ tupleMembers?: TypeDefinition[];
71
+ isOptionalInTuple?: boolean;
72
+ isConstructor?: boolean;
73
+ generics?: TypeDefinition[];
74
+ classDefinition?: ClassDefinition;
75
+ }
76
+ export declare function isIgnoredType(type: TypeDefinition): boolean;
77
+ export declare function isPrimitiveType(type: TypeDefinition): type is {
78
+ name: string;
79
+ };
80
+ export declare function isArrayType(type: TypeDefinition): type is {
81
+ arrayElementType: TypeDefinition;
82
+ };
83
+ export declare function isLiteralType(type: TypeDefinition): type is {
84
+ literalValue: string;
85
+ };
86
+ export declare function isTypeLiteralType(type: TypeDefinition): type is {
87
+ typeLiteralMembers: PropertyDefinition[];
88
+ };
89
+ export declare function isUnionType(type: TypeDefinition): type is {
90
+ unionMembers: TypeDefinition[];
91
+ };
92
+ export declare function isIntersectionType(type: TypeDefinition): type is {
93
+ intersectionMembers: TypeDefinition[];
94
+ };
95
+ export declare function isTupleType(type: TypeDefinition): type is {
96
+ tupleMembers: TypeDefinition[];
97
+ };
98
+ export declare function isClassDefinition(type: TypeDefinition): type is {
99
+ classDefinition: ClassDefinition;
100
+ };
101
+ export declare function hasGenerics(type: TypeDefinition): type is {
102
+ generics: TypeDefinition[];
103
+ };
104
+ export {};
@@ -0,0 +1,20 @@
1
+ import { type RawTypeDefinition, type TypeDefinition } from './index';
2
+ import { ClassDefinition, EnumDefinition, InterfaceDefinition } from './index';
3
+ import { type AnyConstructorFunction } from './package';
4
+ export declare const anyType: {
5
+ name: string;
6
+ };
7
+ export declare const nullType: {
8
+ name: string;
9
+ };
10
+ export declare function getClassDefinition(arg: AnyConstructorFunction | object | string): ClassDefinition | undefined;
11
+ export declare function getInterfaceDefinition(name: string): InterfaceDefinition | undefined;
12
+ export declare function getEnumDefinition(name: string): EnumDefinition | undefined;
13
+ export declare function getTypeAliasDefinition(name: string): TypeDefinition | undefined;
14
+ export declare function getTypeDefinition(typeName: string): TypeDefinition;
15
+ export declare function getEnumNames(enumName: string): string[];
16
+ export declare function getEnumValues(args: {
17
+ [enumName: string]: Record<string, string | number>;
18
+ }): (string | number)[];
19
+ export declare function fillType(rawType: RawTypeDefinition | string | undefined): TypeDefinition;
20
+ export type EnableReflect = object;
@@ -0,0 +1,24 @@
1
+ import { type TypeDefinition } from './index';
2
+ import { type Dictionary } from './package';
3
+ interface ValidateResult {
4
+ success: boolean;
5
+ errorMessage?: string;
6
+ }
7
+ export declare function validateValue(value: unknown, type: TypeDefinition, depth?: number): ValidateResult;
8
+ export declare function validateInstance<T extends object>(instance: T, typeName?: string, depth?: number): ValidateResult;
9
+ export declare function validateArray<T extends object>(array: T[], typeName?: string, depth?: number): ValidateResult;
10
+ export declare function validateDictionary<T extends object>(dict: Dictionary<T>, typeName?: string, depth?: number): ValidateResult;
11
+ interface FailureResult extends ValidateResult {
12
+ cause?: FailureResult;
13
+ }
14
+ export declare function getErrorTraceMessages(failureResult: FailureResult): string;
15
+ export declare function validateFunctionArgument(args: {
16
+ funcName: string;
17
+ optionsObj?: object;
18
+ value?: unknown;
19
+ argName: string;
20
+ type: string;
21
+ optional?: boolean;
22
+ }): void;
23
+ export declare function safeSetValue(target: object, propName: string, value: unknown): void;
24
+ export {};
@@ -1,455 +0,0 @@
1
- export declare const AfterSerialized: PropertyDecorator;
2
-
3
- export declare type Any = any;
4
-
5
- declare type Any_2 = any;
6
-
7
- export declare type AnyConstructorFunction = new (...args: Any[]) => Any;
8
-
9
- declare type AnyConstructorFunction_2 = new (...args: Any_2[]) => Any_2;
10
-
11
- export declare type AnyFunction = (...args: Any[]) => Any;
12
-
13
- export declare type AnyObject = Dictionary<Any>;
14
-
15
- export declare const anyType: {
16
- name: string;
17
- };
18
-
19
- export declare function asBoolean(value: unknown): boolean;
20
-
21
- export declare function asNumber(v: unknown): number;
22
-
23
- export declare function assertType<T>(data: unknown, type: Type, depth?: number): T;
24
-
25
- export declare function asString(v: unknown): string;
26
-
27
- export declare function callDecoratedMethod<Self extends object>(self: Self, metaKey: symbol, ...args: Any[]): Any | undefined;
28
-
29
- export declare type Class<T> = new (...args: Any[]) => T;
30
-
31
- export declare class ClassDefinition {
32
- readonly name: string;
33
- readonly superClassName: string;
34
- readonly superClass: ClassDefinition | undefined;
35
- readonly methods: MethodDefinition[];
36
- readonly properties: PropertyDefinition_2[];
37
- readonly jsClass: AnyConstructorFunction_2;
38
- private readonly _implementationNames;
39
- private readonly _implementations?;
40
- private _allImplementations?;
41
- constructor(def: RawClassDefinition & {
42
- jsClass: AnyConstructorFunction_2;
43
- });
44
- get allMethods(): Dictionary_2<MethodDefinition>;
45
- get allProperties(): Dictionary_2<PropertyDefinition_2>;
46
- get implementations(): ImplementationOfClass[];
47
- get allImplementations(): ImplementationOfClass[];
48
- getProperty(propName: string): PropertyDefinition_2 | undefined;
49
- get type(): TypeDefinition;
50
- isSubClassOf(typeName: string): boolean;
51
- isSuperClassOf(typeName: string): boolean;
52
- toString(): string;
53
- }
54
-
55
- export declare type ClassOrInstance<T> = T | Class<T>;
56
-
57
- export declare function createNewInstance<T>(clazz: Class<T>): any;
58
-
59
- export declare function defineDecoratedProperty(metaKey: symbol): PropertyDecorator;
60
-
61
- export declare function deserialize<T>(json: string | JsonValue, constructorOrTarget?: ClassOrInstance<T>): T;
62
-
63
- export declare function deserializeArray<T>(json: string | JsonValue[], clazz?: Class<T>): T[];
64
-
65
- export declare function deserializeFrom<T extends AnyObject>(data: JsonObject, target: T): void;
66
-
67
- export declare type Dictionary<T> = {
68
- [key: string | symbol]: T;
69
- };
70
-
71
- declare type Dictionary_2<T> = {
72
- [key: string]: T;
73
- };
74
-
75
- export declare const done: () => any;
76
-
77
- export declare type EnableReflect = object;
78
-
79
- export declare class EnumDefinition {
80
- readonly name: string;
81
- readonly members: Map<string, TypeDefinition>;
82
- constructor(def: RawEnumDefinition);
83
- get type(): TypeDefinition;
84
- get names(): string[];
85
- }
86
-
87
- declare interface FailureResult extends ValidateResult {
88
- cause?: FailureResult;
89
- }
90
-
91
- export declare function fillMethod(rawMethod: RawMethodDefinition): MethodDefinition;
92
-
93
- export declare function fillProperty(rawProperty: RawPropertyDefinition): PropertyDefinition_2;
94
-
95
- export declare function fillType(rawType: RawTypeDefinition | string | undefined): TypeDefinition;
96
-
97
- declare type FromJSON<T> = (jsonValue: JsonValue) => T;
98
-
99
- export declare function getAnyValue<T>(target: Any, field: string | number | symbol): T | undefined;
100
-
101
- export declare function getClassByName(className: string): AnyConstructorFunction_2 | undefined;
102
-
103
- export declare function getClassDefinition(arg: AnyConstructorFunction_2 | object | string): ClassDefinition | undefined;
104
-
105
- declare function getClassDefinition_2(arg: AnyConstructorFunction_2 | object | string): ClassDefinition | undefined;
106
-
107
- export declare function getDecoratedProperty(target: object, metaKey: symbol): ReflectPropertyKey | undefined;
108
-
109
- export declare function getDecoratedPropertyValue<V>(target: object, metaKey: symbol): V | undefined;
110
-
111
- export declare function getEnumDefinition(name: string): EnumDefinition | undefined;
112
-
113
- declare function getEnumDefinition_2(name: string): EnumDefinition | undefined;
114
-
115
- export declare function getEnumNames(enumName: string): string[];
116
-
117
- export declare function getEnumValues(args: {
118
- [enumName: string]: Record<string, string | number>;
119
- }): (string | number)[];
120
-
121
- export declare function getErrorTraceMessages(failureResult: FailureResult): string;
122
-
123
- export declare function getInterfaceDefinition(name: string): InterfaceDefinition | undefined;
124
-
125
- declare function getInterfaceDefinition_2(name: string): InterfaceDefinition | undefined;
126
-
127
- export declare function getOrSetValue<T>(target: Any, field: string | number | symbol, defaultWith: () => T): T;
128
-
129
- export declare function getSerializeSettings(clazz: Class<Any>): any;
130
-
131
- export declare function getTypeAliasDefinition(name: string): TypeDefinition | undefined;
132
-
133
- declare function getTypeAliasDefinition_2(name: string): TypeDefinition | undefined;
134
-
135
- export declare function getTypeDef(type: Type | TypeDefinition): TypeDefinition;
136
-
137
- export declare function getTypeDefinition(typeName: string): TypeDefinition;
138
-
139
- export declare function hasDecoratedMethod<Self extends object>(self: Self, metaKey: symbol): boolean;
140
-
141
- export declare function hasGenerics(type: TypeDefinition): type is {
142
- generics: TypeDefinition[];
143
- };
144
-
145
- export declare const IgnoreSerialization: PropertyDecorator;
146
-
147
- declare type ImplementationOfClass = InterfaceDefinition | TypeDefinition;
148
-
149
- declare type ImplementationOfInterface = InterfaceDefinition | ClassDefinition | TypeDefinition;
150
-
151
- export declare class InterfaceDefinition {
152
- readonly name: string;
153
- readonly methods: MethodDefinition[];
154
- readonly properties: PropertyDefinition_2[];
155
- private readonly _implementationNames;
156
- private _implementations?;
157
- private _allImplementations?;
158
- constructor(def: RawInterfaceDefinition);
159
- get implementations(): ImplementationOfInterface[];
160
- get allImplementations(): ImplementationOfInterface[];
161
- get type(): TypeDefinition;
162
- toString(): string;
163
- buildBaseObject(): {};
164
- }
165
-
166
- declare type IPropertyWrapper = {
167
- getField: (owner: object, property: ReflectPropertyKey, fieldSymbol: symbol) => Any;
168
- setField: (owner: object, property: ReflectPropertyKey, newValue: Any, fieldSymbol: symbol) => void;
169
- } & (<T>({ getter, setter, fieldSymbol }: {
170
- getter?: (self: object, property: ReflectPropertyKey) => T;
171
- setter?: (self: object, newValue: T, property: ReflectPropertyKey) => void;
172
- fieldSymbol: symbol;
173
- }) => PropertyDecorator);
174
-
175
- export declare function isArrayType(type: TypeDefinition): type is {
176
- arrayElementType: TypeDefinition;
177
- };
178
-
179
- export declare function isClassDefinition(type: TypeDefinition): type is {
180
- classDefinition: ClassDefinition;
181
- };
182
-
183
- export declare function isDictionary(value: Any): boolean;
184
-
185
- export declare function isIgnoredType(type: TypeDefinition): boolean;
186
-
187
- export declare function isIntersectionType(type: TypeDefinition): type is {
188
- intersectionMembers: TypeDefinition[];
189
- };
190
-
191
- export declare function isLiteralType(type: TypeDefinition): type is {
192
- literalValue: string;
193
- };
194
-
195
- export declare function isNullable(type: Type | TypeDefinition): boolean;
196
-
197
- export declare function isPrimitiveType(type: TypeDefinition): type is {
198
- name: string;
199
- };
200
-
201
- export declare function isTupleType(type: TypeDefinition): type is {
202
- tupleMembers: TypeDefinition[];
203
- };
204
-
205
- export declare function isType(value: unknown, type: Type | TypeDefinition): boolean;
206
-
207
- export declare function isTypeLiteralType(type: TypeDefinition): type is {
208
- typeLiteralMembers: PropertyDefinition_2[];
209
- };
210
-
211
- export declare function isUnionType(type: TypeDefinition): type is {
212
- unionMembers: TypeDefinition[];
213
- };
214
-
215
- export declare const itSelf: (some: Any) => any;
216
-
217
- export declare type JsonObject = {
218
- [propName: string]: JsonValue;
219
- };
220
-
221
- export declare type JsonValue = string | number | boolean | null | JsonObject | JsonObject[];
222
-
223
- export declare interface JsonValueTransform<T> {
224
- fromJson: FromJSON<T>;
225
- toJson: ToJSON<T>;
226
- }
227
-
228
- export declare function Lazy(creator: (self: object, property: ReflectPropertyKey) => Any): PropertyDecorator;
229
-
230
- export declare function mapAllProperties<T extends Mappable>(target: T, map: Mapping<T>): void;
231
-
232
- export declare interface Mappable extends EnableReflect {
233
- mapping(map: Mapping<Mappable>): void;
234
- }
235
-
236
- export declare type Mapping<T extends Mappable> = {
237
- [propName in keyof T]-?: (fieldName?: string | symbol, transform?: {
238
- fromJSON?: (jsonValue: JsonValue) => Mappable;
239
- toJSON?: (obj: Mappable) => JsonValue;
240
- }) => void;
241
- };
242
-
243
- export declare class MethodDefinition {
244
- name: string;
245
- isPrivate: boolean;
246
- isStatic: boolean;
247
- isAsync: boolean;
248
- returnType: TypeDefinition;
249
- args: {
250
- name: string;
251
- type?: TypeDefinition;
252
- isOptional: boolean;
253
- }[];
254
- constructor(def: RawMethodDefinition);
255
- }
256
-
257
- export declare type Nullable<T> = T | null;
258
-
259
- export declare const nullType: {
260
- name: string;
261
- };
262
-
263
- export declare type Optional<T> = T | undefined;
264
-
265
- declare class PropertyDefinition_2 {
266
- name: string;
267
- isOptional: boolean;
268
- isPrivate: boolean;
269
- isStatic: boolean;
270
- type: TypeDefinition;
271
- accessor?: {
272
- getter?: {
273
- isPrivate: boolean;
274
- };
275
- setter?: {
276
- isPrivate: boolean;
277
- };
278
- };
279
- constructor(def: RawPropertyDefinition);
280
- }
281
- export { PropertyDefinition_2 as PropertyDefinition }
282
-
283
- export declare const PropertyWrapper: IPropertyWrapper;
284
-
285
- export declare interface RawClassDefinition {
286
- name: string;
287
- superClassName?: string;
288
- implementations?: string[];
289
- methods?: RawMethodDefinition[];
290
- properties?: RawPropertyDefinition[];
291
- }
292
-
293
- export declare interface RawEnumDefinition {
294
- name: string;
295
- members: {
296
- name: string;
297
- initializer: string | undefined;
298
- }[];
299
- }
300
-
301
- export declare interface RawInterfaceDefinition {
302
- name: string;
303
- implementations?: string[];
304
- methods?: RawMethodDefinition[];
305
- properties?: RawPropertyDefinition[];
306
- }
307
-
308
- export declare interface RawMethodDefinition {
309
- name: string;
310
- isPrivate?: boolean;
311
- isStatic?: boolean;
312
- isAsync?: boolean;
313
- returnType?: RawTypeDef;
314
- args?: {
315
- name: string;
316
- type?: RawTypeDef;
317
- isOptional: boolean;
318
- }[];
319
- }
320
-
321
- export declare interface RawPropertyDefinition {
322
- name: string;
323
- isOptional?: boolean;
324
- isPrivate?: boolean;
325
- isStatic?: boolean;
326
- type?: RawTypeDef;
327
- accessor?: {
328
- getter?: {
329
- isPrivate: boolean;
330
- };
331
- setter?: {
332
- isPrivate: boolean;
333
- };
334
- };
335
- }
336
-
337
- declare type RawTypeDef = string | RawTypeDefinition;
338
-
339
- export declare interface RawTypeDefinition {
340
- arrayElementType?: RawTypeDef;
341
- literalValue?: unknown;
342
- typeLiteralMembers?: RawPropertyDefinition[];
343
- unionMembers?: RawTypeDef[];
344
- intersectionMembers?: RawTypeDef[];
345
- isFunction?: boolean;
346
- tupleMembers?: RawTypeDef[];
347
- isOptionalInTuple?: boolean;
348
- isConstructor?: boolean;
349
- generics?: RawTypeDef[];
350
- }
351
-
352
- export declare const ReflectClass: ClassDecorator;
353
-
354
- export declare const ReflectContext: {
355
- getClassDefinition: typeof getClassDefinition_2;
356
- getInterfaceDefinition: typeof getInterfaceDefinition_2;
357
- getEnumDefinition: typeof getEnumDefinition_2;
358
- getTypeAliasDefinition: typeof getTypeAliasDefinition_2;
359
- };
360
-
361
- export declare type ReflectPropertyKey = string | symbol;
362
-
363
- export declare type ReflectType = StringConstructor | NumberConstructor | BooleanConstructor | ObjectConstructor | ArrayConstructor | FunctionConstructor | AnyConstructorFunction;
364
-
365
- export declare const ReflectValidate: MethodDecorator;
366
-
367
- export declare function registerMappable<T extends Mappable>(mappableClass: Class<T>): void;
368
-
369
- export declare function registerSerializedProperty(target: AnyObject, propName: string, options: SerializedOptions<Any>): void;
370
-
371
- export declare function registerTransform<T>(clazz: Class<T>, transform: JsonValueTransform<T>): void;
372
-
373
- export declare function safeCall(target: object, methodName: string, ...args: unknown[]): unknown;
374
-
375
- export declare function safeSetValue(target: object, propName: string, value: unknown): void;
376
-
377
- /**
378
- * serialize an object to json string
379
- */
380
- export declare function serialize<T>(value: T): string;
381
-
382
- export declare function Serialized<T extends object>(options?: SerializedOptions<T>): PropertyDecorator;
383
-
384
- export declare const SerializedClass: PropertyDecorator;
385
-
386
- export declare function SerializedName(serializedName: string): PropertyDecorator;
387
-
388
- declare type SerializedOptions<T> = {
389
- name?: string;
390
- class?: Class<T>;
391
- fromJSON?: FromJSON<T>;
392
- toJSON?: ToJSON<T>;
393
- };
394
-
395
- export declare function serializeTo<T>(value: T): JsonValue;
396
-
397
- /**
398
- * convert an object to data object
399
- */
400
- export declare function serializeToData<T extends object>(object: T): JsonObject | JsonObject[];
401
-
402
- export declare function setAnyValue<T>(target: Any, field: string | number | symbol, value: T): void;
403
-
404
- export declare function setDefaultIgnored(clazz: Class<Any>, defaultIgnored: boolean): void;
405
-
406
- declare type ToJSON<T> = (obj: T) => JsonValue;
407
-
408
- export declare type Type = string | {
409
- array: Type;
410
- } | {
411
- union: Type[];
412
- } | {
413
- intersection: Type[];
414
- } | {
415
- tuple: Type[];
416
- };
417
-
418
- export declare interface TypeDefinition {
419
- name?: string;
420
- arrayElementType?: TypeDefinition;
421
- literalValue?: string;
422
- typeLiteralMembers?: PropertyDefinition_2[];
423
- unionMembers?: TypeDefinition[];
424
- intersectionMembers?: TypeDefinition[];
425
- isFunction?: boolean;
426
- tupleMembers?: TypeDefinition[];
427
- isOptionalInTuple?: boolean;
428
- isConstructor?: boolean;
429
- generics?: TypeDefinition[];
430
- classDefinition?: ClassDefinition;
431
- }
432
-
433
- export declare function validateArray<T extends object>(array: T[], typeName?: string, depth?: number): ValidateResult;
434
-
435
- export declare function validateDictionary<T extends object>(dict: Dictionary_2<T>, typeName?: string, depth?: number): ValidateResult;
436
-
437
- export declare function validateFunctionArgument(args: {
438
- funcName: string;
439
- optionsObj?: object;
440
- value?: unknown;
441
- argName: string;
442
- type: string;
443
- optional?: boolean;
444
- }): void;
445
-
446
- export declare function validateInstance<T extends object>(instance: T, typeName?: string, depth?: number): ValidateResult;
447
-
448
- declare interface ValidateResult {
449
- success: boolean;
450
- errorMessage?: string;
451
- }
452
-
453
- export declare function validateValue(value: unknown, type: TypeDefinition, depth?: number): ValidateResult;
454
-
455
- export { }
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.11"
9
- }
10
- ]
11
- }