38fa36ca5ad937b4af4a69d70c3ec60755d59ed8
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @typescript-eslint / typescript-estree / dist / convert.d.ts
1 import * as ts from 'typescript';
2 import { TSError } from './node-utils';
3 import { ParserWeakMap, ParserWeakMapESTreeToTSNode } from './parser-options';
4 import { TSESTree, TSNode } from './ts-estree';
5 interface ConverterOptions {
6     errorOnUnknownASTType: boolean;
7     useJSXTextNode: boolean;
8     shouldPreserveNodeMaps: boolean;
9 }
10 /**
11  * Extends and formats a given error object
12  * @param error the error object
13  * @returns converted error object
14  */
15 export declare function convertError(error: any): TSError;
16 export interface ASTMaps {
17     esTreeNodeToTSNodeMap: ParserWeakMapESTreeToTSNode;
18     tsNodeToESTreeNodeMap: ParserWeakMap<TSNode, TSESTree.Node>;
19 }
20 export declare class Converter {
21     private readonly ast;
22     private readonly options;
23     private readonly esTreeNodeToTSNodeMap;
24     private readonly tsNodeToESTreeNodeMap;
25     private allowPattern;
26     private inTypeMode;
27     /**
28      * Converts a TypeScript node into an ESTree node
29      * @param ast the full TypeScript AST
30      * @param options additional options for the conversion
31      * @returns the converted ESTreeNode
32      */
33     constructor(ast: ts.SourceFile, options: ConverterOptions);
34     getASTMaps(): ASTMaps;
35     convertProgram(): TSESTree.Program;
36     /**
37      * Converts a TypeScript node into an ESTree node.
38      * @param node the child ts.Node
39      * @param parent parentNode
40      * @param inTypeMode flag to determine if we are in typeMode
41      * @param allowPattern flag to determine if patterns are allowed
42      * @returns the converted ESTree node
43      */
44     private converter;
45     /**
46      * Fixes the exports of the given ts.Node
47      * @param node the ts.Node
48      * @param result result
49      * @returns the ESTreeNode with fixed exports
50      */
51     private fixExports;
52     /**
53      * Register specific TypeScript node into map with first ESTree node provided
54      */
55     private registerTSNodeInNodeMap;
56     /**
57      * Converts a TypeScript node into an ESTree node.
58      * @param child the child ts.Node
59      * @param parent parentNode
60      * @returns the converted ESTree node
61      */
62     private convertPattern;
63     /**
64      * Converts a TypeScript node into an ESTree node.
65      * @param child the child ts.Node
66      * @param parent parentNode
67      * @returns the converted ESTree node
68      */
69     private convertChild;
70     /**
71      * Converts a TypeScript node into an ESTree node.
72      * @param child the child ts.Node
73      * @param parent parentNode
74      * @returns the converted ESTree node
75      */
76     private convertType;
77     private createNode;
78     /**
79      * Converts a child into a type annotation. This creates an intermediary
80      * TypeAnnotation node to match what Flow does.
81      * @param child The TypeScript AST node to convert.
82      * @param parent parentNode
83      * @returns The type annotation node.
84      */
85     private convertTypeAnnotation;
86     /**
87      * Coverts body Nodes and add a directive field to StringLiterals
88      * @param nodes of ts.Node
89      * @param parent parentNode
90      * @returns Array of body statements
91      */
92     private convertBodyExpressions;
93     /**
94      * Converts a ts.Node's typeArguments to TSTypeParameterInstantiation node
95      * @param typeArguments ts.NodeArray typeArguments
96      * @param node parent used to create this node
97      * @returns TypeParameterInstantiation node
98      */
99     private convertTypeArgumentsToTypeParameters;
100     /**
101      * Converts a ts.Node's typeParameters to TSTypeParameterDeclaration node
102      * @param typeParameters ts.Node typeParameters
103      * @returns TypeParameterDeclaration node
104      */
105     private convertTSTypeParametersToTypeParametersDeclaration;
106     /**
107      * Converts an array of ts.Node parameters into an array of ESTreeNode params
108      * @param parameters An array of ts.Node params to be converted
109      * @returns an array of converted ESTreeNode params
110      */
111     private convertParameters;
112     /**
113      * For nodes that are copied directly from the TypeScript AST into
114      * ESTree mostly as-is. The only difference is the addition of a type
115      * property instead of a kind property. Recursively copies all children.
116      */
117     private deeplyCopy;
118     /**
119      * Converts a TypeScript JSX node.tagName into an ESTree node.name
120      * @param node the tagName object from a JSX ts.Node
121      * @param parent
122      * @returns the converted ESTree name object
123      */
124     private convertJSXTagName;
125     /**
126      * Applies the given TS modifiers to the given result object.
127      * @param result
128      * @param modifiers original ts.Nodes from the node.modifiers array
129      * @returns the current result object will be mutated
130      * @deprecated This method adds not standardized `modifiers` property in nodes
131      */
132     private applyModifiersToResult;
133     /**
134      * Uses the provided range location to adjust the location data of the given Node
135      * @param result The node that will have its location data mutated
136      * @param childRange The child node range used to expand location
137      */
138     private fixParentLocation;
139     /**
140      * Converts a TypeScript node into an ESTree node.
141      * The core of the conversion logic:
142      * Identify and convert each relevant TypeScript SyntaxKind
143      * @param node the child ts.Node
144      * @param parent parentNode
145      * @returns the converted ESTree node
146      */
147     private convertNode;
148 }
149 export {};
150 //# sourceMappingURL=convert.d.ts.map