This commit is contained in:
60
src/types.ts
Normal file
60
src/types.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
export interface TypeDefinition {
|
||||
name: string;
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
export type TypeNode =
|
||||
| PrimitiveType
|
||||
| ArrayType
|
||||
| ObjectType
|
||||
| UnionType
|
||||
| LiteralType
|
||||
| OptionalType;
|
||||
|
||||
export interface PrimitiveType {
|
||||
kind: 'primitive';
|
||||
type: 'string' | 'number' | 'boolean' | 'null' | 'unknown' | 'any';
|
||||
}
|
||||
|
||||
export interface ArrayType {
|
||||
kind: 'array';
|
||||
elementType: TypeNode;
|
||||
}
|
||||
|
||||
export interface ObjectType {
|
||||
kind: 'object';
|
||||
properties: Property[];
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface Property {
|
||||
name: string;
|
||||
type: TypeNode;
|
||||
optional: boolean;
|
||||
}
|
||||
|
||||
export interface UnionType {
|
||||
kind: 'union';
|
||||
types: TypeNode[];
|
||||
}
|
||||
|
||||
export interface LiteralType {
|
||||
kind: 'literal';
|
||||
value: string | number | boolean;
|
||||
}
|
||||
|
||||
export interface OptionalType {
|
||||
kind: 'optional';
|
||||
type: TypeNode;
|
||||
}
|
||||
|
||||
export interface TypeInferenceOptions {
|
||||
rootName?: string;
|
||||
detectUnions?: boolean;
|
||||
literalThreshold?: number;
|
||||
}
|
||||
|
||||
export interface ParseResult {
|
||||
types: TypeDefinition[];
|
||||
warnings: string[];
|
||||
}
|
||||
Reference in New Issue
Block a user