UNPKG

2.88 kBTypeScriptView Raw
1import { JSONSchema4Type } from 'json-schema';
2export declare type AST_TYPE = AST['type'];
3export declare type AST = TAny | TArray | TBoolean | TEnum | TInterface | TNamedInterface | TIntersection | TLiteral | TNumber | TNull | TObject | TReference | TString | TTuple | TUnion | TUnknown | TCustomType;
4export interface AbstractAST {
5 comment?: string;
6 keyName?: string;
7 standaloneName?: string;
8 type: AST_TYPE;
9}
10export declare type ASTWithComment = AST & {
11 comment: string;
12};
13export declare type ASTWithName = AST & {
14 keyName: string;
15};
16export declare type ASTWithStandaloneName = AST & {
17 standaloneName: string;
18};
19export declare function hasComment(ast: AST): ast is ASTWithComment;
20export declare function hasStandaloneName(ast: AST): ast is ASTWithStandaloneName;
21export interface TAny extends AbstractAST {
22 type: 'ANY';
23}
24export interface TArray extends AbstractAST {
25 type: 'ARRAY';
26 params: AST;
27}
28export interface TBoolean extends AbstractAST {
29 type: 'BOOLEAN';
30}
31export interface TEnum extends AbstractAST {
32 standaloneName: string;
33 type: 'ENUM';
34 params: TEnumParam[];
35}
36export interface TEnumParam {
37 ast: AST;
38 keyName: string;
39}
40export interface TInterface extends AbstractAST {
41 type: 'INTERFACE';
42 params: TInterfaceParam[];
43 superTypes: TNamedInterface[];
44}
45export interface TNamedInterface extends AbstractAST {
46 standaloneName: string;
47 type: 'INTERFACE';
48 params: TInterfaceParam[];
49 superTypes: TNamedInterface[];
50}
51export interface TInterfaceParam {
52 ast: AST;
53 keyName: string;
54 isRequired: boolean;
55 isPatternProperty: boolean;
56 isUnreachableDefinition: boolean;
57}
58export interface TIntersection extends AbstractAST {
59 type: 'INTERSECTION';
60 params: AST[];
61}
62export interface TLiteral extends AbstractAST {
63 params: JSONSchema4Type;
64 type: 'LITERAL';
65}
66export interface TNumber extends AbstractAST {
67 type: 'NUMBER';
68}
69export interface TNull extends AbstractAST {
70 type: 'NULL';
71}
72export interface TObject extends AbstractAST {
73 type: 'OBJECT';
74}
75export interface TReference extends AbstractAST {
76 type: 'REFERENCE';
77 params: string;
78}
79export interface TString extends AbstractAST {
80 type: 'STRING';
81}
82export interface TTuple extends AbstractAST {
83 type: 'TUPLE';
84 params: AST[];
85 spreadParam?: AST;
86 minItems: number;
87 maxItems?: number;
88}
89export interface TUnion extends AbstractAST {
90 type: 'UNION';
91 params: AST[];
92}
93export interface TUnknown extends AbstractAST {
94 type: 'UNKNOWN';
95}
96export interface TCustomType extends AbstractAST {
97 type: 'CUSTOM_TYPE';
98 params: string;
99}
100export declare const T_ANY: TAny;
101export declare const T_ANY_ADDITIONAL_PROPERTIES: TAny & ASTWithName;
102export declare const T_UNKNOWN: TUnknown;
103export declare const T_UNKNOWN_ADDITIONAL_PROPERTIES: TUnknown & ASTWithName;