1 | import * as ts from 'typescript';
|
2 | import { AST_NODE_TYPES, AST_TOKEN_TYPES, TSESTree } from './ts-estree';
|
3 | declare const SyntaxKind: typeof ts.SyntaxKind;
|
4 | interface TokenToText extends TSESTree.PunctuatorTokenToText {
|
5 | [SyntaxKind.ImportKeyword]: 'import';
|
6 | [SyntaxKind.InKeyword]: 'in';
|
7 | [SyntaxKind.InstanceOfKeyword]: 'instanceof';
|
8 | [SyntaxKind.NewKeyword]: 'new';
|
9 | [SyntaxKind.KeyOfKeyword]: 'keyof';
|
10 | [SyntaxKind.ReadonlyKeyword]: 'readonly';
|
11 | [SyntaxKind.UniqueKeyword]: 'unique';
|
12 | }
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | export declare function isAssignmentOperator<T extends ts.SyntaxKind>(operator: ts.Token<T>): boolean;
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | export declare function isLogicalOperator<T extends ts.SyntaxKind>(operator: ts.Token<T>): boolean;
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 | export declare function getTextForTokenKind<T extends ts.SyntaxKind>(kind: T): T extends keyof TokenToText ? TokenToText[T] : string | undefined;
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | export declare function isESTreeClassMember(node: ts.Node): boolean;
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | export declare function hasModifier(modifierKind: ts.KeywordSyntaxKind, node: ts.Node): boolean;
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 | export declare function getLastModifier(node: ts.Node): ts.Modifier | null;
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | export declare function isComma(token: ts.Node): token is ts.Token<ts.SyntaxKind.CommaToken>;
|
56 |
|
57 |
|
58 |
|
59 |
|
60 |
|
61 | export declare function isComment(node: ts.Node): boolean;
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | export declare function isJSDocComment(node: ts.Node): node is ts.JSDoc;
|
68 |
|
69 |
|
70 |
|
71 |
|
72 |
|
73 | export declare function getBinaryExpressionType<T extends ts.SyntaxKind>(operator: ts.Token<T>): AST_NODE_TYPES.AssignmentExpression | AST_NODE_TYPES.LogicalExpression | AST_NODE_TYPES.BinaryExpression;
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 | export declare function getLineAndCharacterFor(pos: number, ast: ts.SourceFile): TSESTree.Position;
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 | export declare function getLocFor(start: number, end: number, ast: ts.SourceFile): TSESTree.SourceLocation;
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 | export declare function canContainDirective(node: ts.SourceFile | ts.Block | ts.ModuleBlock | ts.ClassStaticBlockDeclaration): boolean;
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | export declare function getRange(node: ts.Node, ast: ts.SourceFile): [number, number];
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 | export declare function isToken(node: ts.Node): node is ts.Token<ts.TokenSyntaxKind>;
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 | export declare function isJSXToken(node: ts.Node): boolean;
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 | export declare function getDeclarationKind(node: ts.VariableDeclarationList): 'let' | 'const' | 'var';
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 | export declare function getTSNodeAccessibility(node: ts.Node): 'public' | 'protected' | 'private' | null;
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 | export declare function findNextToken(previousToken: ts.TextRange, parent: ts.Node, ast: ts.SourceFile): ts.Node | undefined;
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 | export declare function findFirstMatchingAncestor(node: ts.Node, predicate: (node: ts.Node) => boolean): ts.Node | undefined;
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 | export declare function hasJSXAncestor(node: ts.Node): boolean;
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 | export declare function unescapeStringLiteralText(text: string): string;
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 | export declare function isComputedProperty(node: ts.Node): node is ts.ComputedPropertyName;
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 | export declare function isOptional(node: {
|
167 | questionToken?: ts.QuestionToken;
|
168 | }): boolean;
|
169 |
|
170 |
|
171 |
|
172 | export declare function isChainExpression(node: TSESTree.Node): node is TSESTree.ChainExpression;
|
173 |
|
174 |
|
175 |
|
176 | export declare function isChildUnwrappableOptionalChain(node: ts.PropertyAccessExpression | ts.ElementAccessExpression | ts.CallExpression | ts.NonNullExpression, child: TSESTree.Node): boolean;
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 | export declare function getTokenType(token: ts.Identifier | ts.Token<ts.SyntaxKind>): Exclude<AST_TOKEN_TYPES, AST_TOKEN_TYPES.Line | AST_TOKEN_TYPES.Block>;
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 | export declare function convertToken(token: ts.Token<ts.TokenSyntaxKind>, ast: ts.SourceFile): TSESTree.Token;
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 | export declare function convertTokens(ast: ts.SourceFile): TSESTree.Token[];
|
196 | export declare class TSError extends Error {
|
197 | readonly fileName: string;
|
198 | readonly index: number;
|
199 | readonly lineNumber: number;
|
200 | readonly column: number;
|
201 | constructor(message: string, fileName: string, index: number, lineNumber: number, column: number);
|
202 | }
|
203 | /**
|
204 | * @param ast the AST object
|
205 | * @param start the index at which the error starts
|
206 | * @param message the error message
|
207 | * @returns converted error object
|
208 | */
|
209 | export declare function createError(ast: ts.SourceFile, start: number, message: string): TSError;
|
210 | /**
|
211 | * @param n the TSNode
|
212 | * @param ast the TS AST
|
213 | */
|
214 | export declare function nodeHasTokens(n: ts.Node, ast: ts.SourceFile): boolean;
|
215 | /**
|
216 | * Like `forEach`, but suitable for use with numbers and strings (which may be falsy).
|
217 | * @template T
|
218 | * @template U
|
219 | * @param array
|
220 | * @param callback
|
221 | */
|
222 | export declare function firstDefined<T, U>(array: readonly T[] | undefined, callback: (element: T, index: number) => U | undefined): U | undefined;
|
223 | export {};
|
224 |
|
\ | No newline at end of file |