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