.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / tsutils / util / util.d.ts
1 import * as ts from 'typescript';\r
2 import { NodeWrap } from './convert-ast';\r
3 export declare function getChildOfKind<T extends ts.SyntaxKind>(node: ts.Node, kind: T, sourceFile?: ts.SourceFile): ts.Token<T> | undefined;\r
4 export declare function isTokenKind(kind: ts.SyntaxKind): boolean;\r
5 export declare function isNodeKind(kind: ts.SyntaxKind): boolean;\r
6 export declare function isAssignmentKind(kind: ts.SyntaxKind): boolean;\r
7 export declare function isTypeNodeKind(kind: ts.SyntaxKind): boolean;\r
8 export declare function isJsDocKind(kind: ts.SyntaxKind): boolean;\r
9 export declare function isKeywordKind(kind: ts.SyntaxKind): boolean;\r
10 export declare function isThisParameter(parameter: ts.ParameterDeclaration): boolean;\r
11 export declare function getModifier(node: ts.Node, kind: ts.Modifier['kind']): ts.Modifier | undefined;\r
12 export declare function hasModifier(modifiers: ts.ModifiersArray | undefined, ...kinds: Array<ts.Modifier['kind']>): boolean;\r
13 export declare function isParameterProperty(node: ts.ParameterDeclaration): boolean;\r
14 export declare function hasAccessModifier(node: ts.ClassElement | ts.ParameterDeclaration): boolean;\r
15 export declare const isNodeFlagSet: (node: ts.Node, flag: ts.NodeFlags) => boolean;\r
16 export declare const isTypeFlagSet: (type: ts.Type, flag: ts.TypeFlags) => boolean;\r
17 export declare const isSymbolFlagSet: (symbol: ts.Symbol, flag: ts.SymbolFlags) => boolean;\r
18 export declare function isObjectFlagSet(objectType: ts.ObjectType, flag: ts.ObjectFlags): boolean;\r
19 export declare function isModifierFlagSet(node: ts.Node, flag: ts.ModifierFlags): boolean;\r
20 export declare function getPreviousStatement(statement: ts.Statement): ts.Statement | undefined;\r
21 export declare function getNextStatement(statement: ts.Statement): ts.Statement | undefined;\r
22 /** Returns the token before the start of `node` or `undefined` if there is none. */\r
23 export declare function getPreviousToken(node: ts.Node, sourceFile?: ts.SourceFile): ts.Node | undefined;\r
24 /** Returns the next token that begins after the end of `node`. Returns `undefined` for SourceFile and EndOfFileToken */\r
25 export declare function getNextToken(node: ts.Node, sourceFile?: ts.SourceFile): ts.Node | undefined;\r
26 /** Returns the token at or following the specified position or undefined if none is found inside `parent`. */\r
27 export declare function getTokenAtPosition(parent: ts.Node, pos: number, sourceFile?: ts.SourceFile, allowJsDoc?: boolean): ts.Node | undefined;\r
28 /**\r
29  * Return the comment at the specified position.\r
30  * You can pass an optional `parent` to avoid some work finding the corresponding token starting at `sourceFile`.\r
31  * If the `parent` parameter is passed, `pos` must be between `parent.pos` and `parent.end`.\r
32 */\r
33 export declare function getCommentAtPosition(sourceFile: ts.SourceFile, pos: number, parent?: ts.Node): ts.CommentRange | undefined;\r
34 /**\r
35  * Returns whether the specified position is inside a comment.\r
36  * You can pass an optional `parent` to avoid some work finding the corresponding token starting at `sourceFile`.\r
37  * If the `parent` parameter is passed, `pos` must be between `parent.pos` and `parent.end`.\r
38  */\r
39 export declare function isPositionInComment(sourceFile: ts.SourceFile, pos: number, parent?: ts.Node): boolean;\r
40 export declare function commentText(sourceText: string, comment: ts.CommentRange): string;\r
41 /** Returns the deepest AST Node at `pos`. Returns undefined if `pos` is outside of the range of `node` */\r
42 export declare function getAstNodeAtPosition(node: ts.Node, pos: number): ts.Node | undefined;\r
43 /**\r
44  * Returns the NodeWrap of deepest AST node that contains `pos` between its `pos` and `end`.\r
45  * Only returns undefined if pos is outside of `wrap`\r
46  */\r
47 export declare function getWrappedNodeAtPosition(wrap: NodeWrap, pos: number): NodeWrap | undefined;\r
48 export declare function getPropertyName(propertyName: ts.PropertyName): string | undefined;\r
49 export declare function forEachDestructuringIdentifier<T>(pattern: ts.BindingPattern, fn: (element: ts.BindingElement & {\r
50     name: ts.Identifier;\r
51 }) => T): T | undefined;\r
52 export declare function forEachDeclaredVariable<T>(declarationList: ts.VariableDeclarationList, cb: (element: (ts.VariableDeclaration | ts.BindingElement) & {\r
53     name: ts.Identifier;\r
54 }) => T): T | undefined;\r
55 export declare enum VariableDeclarationKind {\r
56     Var = 0,\r
57     Let = 1,\r
58     Const = 2\r
59 }\r
60 export declare function getVariableDeclarationKind(declarationList: ts.VariableDeclarationList): VariableDeclarationKind;\r
61 export declare function isBlockScopedVariableDeclarationList(declarationList: ts.VariableDeclarationList): boolean;\r
62 export declare function isBlockScopedVariableDeclaration(declaration: ts.VariableDeclaration): boolean;\r
63 export declare function isBlockScopedDeclarationStatement(statement: ts.Statement): statement is ts.DeclarationStatement;\r
64 export declare function isInSingleStatementContext(statement: ts.Statement): boolean;\r
65 export declare enum ScopeBoundary {\r
66     None = 0,\r
67     Function = 1,\r
68     Block = 2,\r
69     Type = 4,\r
70     ConditionalType = 8\r
71 }\r
72 export declare enum ScopeBoundarySelector {\r
73     Function = 1,\r
74     Block = 3,\r
75     Type = 7,\r
76     InferType = 8\r
77 }\r
78 export declare function isScopeBoundary(node: ts.Node): ScopeBoundary;\r
79 export declare function isTypeScopeBoundary(node: ts.Node): ScopeBoundary;\r
80 export declare function isFunctionScopeBoundary(node: ts.Node): ScopeBoundary;\r
81 export declare function isBlockScopeBoundary(node: ts.Node): ScopeBoundary;\r
82 /** Returns true for scope boundaries that have their own `this` reference instead of inheriting it from the containing scope */\r
83 export declare function hasOwnThisReference(node: ts.Node): boolean;\r
84 export declare function isFunctionWithBody(node: ts.Node): node is ts.FunctionLikeDeclaration & {\r
85     body: {};\r
86 };\r
87 /**\r
88  * Iterate over all tokens of `node`\r
89  *\r
90  * @param node The node whose tokens should be visited\r
91  * @param cb Is called for every token contained in `node`\r
92  */\r
93 export declare function forEachToken(node: ts.Node, cb: (node: ts.Node) => void, sourceFile?: ts.SourceFile): void;\r
94 export declare type ForEachTokenCallback = (fullText: string, kind: ts.SyntaxKind, range: ts.TextRange, parent: ts.Node) => void;\r
95 /**\r
96  * Iterate over all tokens and trivia of `node`\r
97  *\r
98  * @description JsDoc comments are treated like regular comments\r
99  *\r
100  * @param node The node whose tokens should be visited\r
101  * @param cb Is called for every token contained in `node` and trivia before the token\r
102  */\r
103 export declare function forEachTokenWithTrivia(node: ts.Node, cb: ForEachTokenCallback, sourceFile?: ts.SourceFile): void;\r
104 export declare type ForEachCommentCallback = (fullText: string, comment: ts.CommentRange) => void;\r
105 /** Iterate over all comments owned by `node` or its children */\r
106 export declare function forEachComment(node: ts.Node, cb: ForEachCommentCallback, sourceFile?: ts.SourceFile): void;\r
107 export interface LineRange extends ts.TextRange {\r
108     contentLength: number;\r
109 }\r
110 export declare function getLineRanges(sourceFile: ts.SourceFile): LineRange[];\r
111 /** Get the line break style used in sourceFile. This function only looks at the first line break. If there is none, \n is assumed. */\r
112 export declare function getLineBreakStyle(sourceFile: ts.SourceFile): "\n" | "\r\n";\r
113 /**\r
114  * Determines whether the given text parses as a standalone identifier.\r
115  * This is not a guarantee that it works in every context. The property name in PropertyAccessExpressions for example allows reserved words.\r
116  * Depending on the context it could be parsed as contextual keyword or TypeScript keyword.\r
117  */\r
118 export declare function isValidIdentifier(text: string, languageVersion?: ts.ScriptTarget): boolean;\r
119 /**\r
120  * Determines whether the given text can be used to access a property with a PropertyAccessExpression while preserving the property's name.\r
121  */\r
122 export declare function isValidPropertyAccess(text: string, languageVersion?: ts.ScriptTarget): boolean;\r
123 /**\r
124  * Determines whether the given text can be used as unquoted name of a property declaration while preserving the property's name.\r
125  */\r
126 export declare function isValidPropertyName(text: string, languageVersion?: ts.ScriptTarget): boolean;\r
127 /**\r
128  * Determines whether the given text can be parsed as a numeric literal.\r
129  */\r
130 export declare function isValidNumericLiteral(text: string, languageVersion?: ts.ScriptTarget): boolean;\r
131 /**\r
132  * Determines whether the given text can be used as JSX tag or attribute name while preserving the exact name.\r
133  */\r
134 export declare function isValidJsxIdentifier(text: string, languageVersion?: ts.ScriptTarget): boolean;\r
135 export declare function isNumericPropertyName(name: string | ts.__String): boolean;\r
136 export declare function isSameLine(sourceFile: ts.SourceFile, pos1: number, pos2: number): boolean;\r
137 export declare enum SideEffectOptions {\r
138     None = 0,\r
139     TaggedTemplate = 1,\r
140     Constructor = 2,\r
141     JsxElement = 4\r
142 }\r
143 export declare function hasSideEffects(node: ts.Expression, options?: SideEffectOptions): boolean;\r
144 /** Returns the VariableDeclaration or ParameterDeclaration that contains the BindingElement */\r
145 export declare function getDeclarationOfBindingElement(node: ts.BindingElement): ts.VariableDeclaration | ts.ParameterDeclaration;\r
146 export declare function isExpressionValueUsed(node: ts.Expression): boolean;\r
147 export declare enum AccessKind {\r
148     None = 0,\r
149     Read = 1,\r
150     Write = 2,\r
151     Delete = 4,\r
152     ReadWrite = 3,\r
153     Modification = 6\r
154 }\r
155 export declare function getAccessKind(node: ts.Node): AccessKind;\r
156 export declare function isReassignmentTarget(node: ts.Expression): boolean;\r
157 export declare function canHaveJsDoc(node: ts.Node): node is ts.HasJSDoc;\r
158 /** Gets the JSDoc of a node. For performance reasons this function should only be called when `canHaveJsDoc` returns true. */\r
159 export declare function getJsDoc(node: ts.Node, sourceFile?: ts.SourceFile): ts.JSDoc[];\r
160 /**\r
161  * Parses the JsDoc of any node. This function is made for nodes that don't get their JsDoc parsed by the TypeScript parser.\r
162  *\r
163  * @param considerTrailingComments When set to `true` this function uses the trailing comments if the node starts on the same line\r
164  *                                 as the previous node ends.\r
165  */\r
166 export declare function parseJsDocOfNode(node: ts.Node, considerTrailingComments?: boolean, sourceFile?: ts.SourceFile): ts.JSDoc[];\r
167 export declare enum ImportKind {\r
168     ImportDeclaration = 1,\r
169     ImportEquals = 2,\r
170     ExportFrom = 4,\r
171     DynamicImport = 8,\r
172     Require = 16,\r
173     ImportType = 32,\r
174     All = 63,\r
175     AllImports = 59,\r
176     AllStaticImports = 3,\r
177     AllImportExpressions = 24,\r
178     AllRequireLike = 18\r
179 }\r
180 export declare function findImports(sourceFile: ts.SourceFile, kinds: ImportKind, ignoreFileName?: boolean): (ts.StringLiteral | ts.NoSubstitutionTemplateLiteral)[];\r
181 export declare type ImportLike = ts.ImportDeclaration | ts.ImportEqualsDeclaration & {\r
182     moduleReference: ts.ExternalModuleReference;\r
183 } | ts.ExportDeclaration & {\r
184     moduleSpecifier: {};\r
185 } | ts.CallExpression & {\r
186     expression: ts.Token<ts.SyntaxKind.ImportKeyword> | ts.Identifier & {\r
187         text: 'require';\r
188     };\r
189     arguments: [ts.Expression, ...ts.Expression[]];\r
190 } | ts.ImportTypeNode;\r
191 export declare function findImportLikeNodes(sourceFile: ts.SourceFile, kinds: ImportKind, ignoreFileName?: boolean): ImportLike[];\r
192 /**\r
193  * Ambient context means the statement itself has the `declare` keyword\r
194  * or is inside a `declare namespace`,  `delcare module` or `declare global`.\r
195  */\r
196 export declare function isStatementInAmbientContext(node: ts.Statement): boolean;\r
197 /** Includes `declare namespace`, `declare module` and `declare global` and namespace nested in one of the aforementioned. */\r
198 export declare function isAmbientModuleBlock(node: ts.Node): node is ts.ModuleBlock;\r
199 export declare function getIIFE(func: ts.FunctionExpression | ts.ArrowFunction): ts.CallExpression | undefined;\r
200 export declare type StrictCompilerOption = 'noImplicitAny' | 'noImplicitThis' | 'strictNullChecks' | 'strictFunctionTypes' | 'strictPropertyInitialization' | 'alwaysStrict' | 'strictBindCallApply';\r
201 export declare function isStrictCompilerOptionEnabled(options: ts.CompilerOptions, option: StrictCompilerOption): boolean;\r
202 export declare type BooleanCompilerOptions = {\r
203     [K in keyof ts.CompilerOptions]: NonNullable<ts.CompilerOptions[K]> extends boolean ? K : never;\r
204 } extends {\r
205     [_ in keyof ts.CompilerOptions]: infer U;\r
206 } ? U : never;\r
207 /**\r
208  * Checks if a given compiler option is enabled.\r
209  * It handles dependencies of options, e.g. `declaration` is implicitly enabled by `composite` or `strictNullChecks` is enabled by `strict`.\r
210  * However, it does not check dependencies that are already checked and reported as errors, e.g. `checkJs` without `allowJs`.\r
211  * This function only handles boolean flags.\r
212  */\r
213 export declare function isCompilerOptionEnabled(options: ts.CompilerOptions, option: BooleanCompilerOptions | 'stripInternal'): boolean;\r
214 /**\r
215  * Has nothing to do with `isAmbientModuleBlock`.\r
216  *\r
217  * @returns `true` if it's a global augmentation or has a string name.\r
218  */\r
219 export declare function isAmbientModule(node: ts.ModuleDeclaration): boolean;\r
220 /**\r
221  * @deprecated use `getTsCheckDirective` instead since `// @ts-nocheck` is no longer restricted to JS files.\r
222  * @returns the last `// @ts-check` or `// @ts-nocheck` directive in the given file.\r
223  */\r
224 export declare function getCheckJsDirective(source: string): ts.CheckJsDirective | undefined;\r
225 /** @returns the last `// @ts-check` or `// @ts-nocheck` directive in the given file. */\r
226 export declare function getTsCheckDirective(source: string): ts.CheckJsDirective | undefined;\r
227 export declare function isConstAssertion(node: ts.AssertionExpression): boolean;\r
228 /** Detects whether an expression is affected by an enclosing 'as const' assertion and therefore treated literally. */\r
229 export declare function isInConstContext(node: ts.Expression): boolean;\r
230 /** Returns true for `Object.defineProperty(o, 'prop', {value, writable: false})` and  `Object.defineProperty(o, 'prop', {get: () => 1})`*/\r
231 export declare function isReadonlyAssignmentDeclaration(node: ts.CallExpression, checker: ts.TypeChecker): boolean;\r
232 /** Determines whether a call to `Object.defineProperty` is statically analyzable. */\r
233 export declare function isBindableObjectDefinePropertyCall(node: ts.CallExpression): boolean;\r
234 export interface WellKnownSymbolLiteral extends ts.PropertyAccessExpression {\r
235     expression: ts.Identifier & {\r
236         text: 'Symbol';\r
237         escapedText: 'symbol';\r
238     };\r
239 }\r
240 export declare function isWellKnownSymbolLiterally(node: ts.Expression): node is WellKnownSymbolLiteral;\r
241 export interface PropertyName {\r
242     displayName: string;\r
243     symbolName: ts.__String;\r
244 }\r
245 /** @deprecated typescript 4.3 removed the concept of literal well known symbols. Use `getPropertyNameFromType` instead. */\r
246 export declare function getPropertyNameOfWellKnownSymbol(node: WellKnownSymbolLiteral): PropertyName;\r
247 export interface LateBoundPropertyNames {\r
248     /** Whether all constituents are literal names. */\r
249     known: boolean;\r
250     names: PropertyName[];\r
251 }\r
252 export declare function getLateBoundPropertyNames(node: ts.Expression, checker: ts.TypeChecker): LateBoundPropertyNames;\r
253 export declare function getLateBoundPropertyNamesOfPropertyName(node: ts.PropertyName, checker: ts.TypeChecker): LateBoundPropertyNames;\r
254 /** Most declarations demand there to be only one statically known name, e.g. class members with computed name. */\r
255 export declare function getSingleLateBoundPropertyNameOfPropertyName(node: ts.PropertyName, checker: ts.TypeChecker): PropertyName | undefined;\r
256 export declare function unwrapParentheses(node: ts.Expression): ts.Expression;\r
257 export declare function formatPseudoBigInt(v: ts.PseudoBigInt): `${string}n` | `-${string}n`;\r
258 /**\r
259  * Determines whether the given `SwitchStatement`'s `case` clauses cover every possible value of the switched expression.\r
260  * The logic is the same as TypeScript's control flow analysis.\r
261  * This does **not** check whether all `case` clauses do a certain action like assign a variable or return a value.\r
262  * This function ignores the `default` clause if present.\r
263  */\r
264 export declare function hasExhaustiveCaseClauses(node: ts.SwitchStatement, checker: ts.TypeChecker): boolean;\r
265 export declare function getBaseOfClassLikeExpression(node: ts.ClassLikeDeclaration): ts.ExpressionWithTypeArguments | undefined;\r