@tslite/services 0.0.0-stage → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/LICENSE +55 -0
  2. package/NOTICE +13 -0
  3. package/dist/_namespaces/edit.d.ts +8 -0
  4. package/dist/_namespaces/edit.js +11 -0
  5. package/dist/_namespaces/ts.Completions.StringCompletions.d.ts +1 -0
  6. package/dist/_namespaces/ts.Completions.StringCompletions.js +2 -0
  7. package/dist/_namespaces/ts.Completions.d.ts +2 -0
  8. package/dist/_namespaces/ts.Completions.js +3 -0
  9. package/dist/_namespaces/ts.FindAllReferences.d.ts +2 -0
  10. package/dist/_namespaces/ts.FindAllReferences.js +3 -0
  11. package/dist/_namespaces/ts.GoToDefinition.d.ts +1 -0
  12. package/dist/_namespaces/ts.GoToDefinition.js +2 -0
  13. package/dist/_namespaces/ts.NavigationBar.d.ts +1 -0
  14. package/dist/_namespaces/ts.NavigationBar.js +2 -0
  15. package/dist/_namespaces/ts.OrganizeImports.d.ts +1 -0
  16. package/dist/_namespaces/ts.OrganizeImports.js +2 -0
  17. package/dist/_namespaces/ts.OutliningElementsCollector.d.ts +1 -0
  18. package/dist/_namespaces/ts.OutliningElementsCollector.js +2 -0
  19. package/dist/_namespaces/ts.Rename.d.ts +1 -0
  20. package/dist/_namespaces/ts.Rename.js +2 -0
  21. package/dist/_namespaces/ts.SignatureHelp.d.ts +1 -0
  22. package/dist/_namespaces/ts.SignatureHelp.js +2 -0
  23. package/dist/_namespaces/ts.SmartSelectionRange.d.ts +1 -0
  24. package/dist/_namespaces/ts.SmartSelectionRange.js +2 -0
  25. package/dist/_namespaces/ts.SymbolDisplay.d.ts +1 -0
  26. package/dist/_namespaces/ts.SymbolDisplay.js +2 -0
  27. package/dist/_namespaces/ts.codefix.d.ts +26 -0
  28. package/dist/_namespaces/ts.codefix.js +27 -0
  29. package/dist/_namespaces/ts.d.ts +17 -0
  30. package/dist/_namespaces/ts.formatting.d.ts +7 -0
  31. package/dist/_namespaces/ts.formatting.js +8 -0
  32. package/dist/_namespaces/ts.js +20 -0
  33. package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.d.ts +1 -0
  34. package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.js +2 -0
  35. package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.d.ts +1 -0
  36. package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.js +2 -0
  37. package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.d.ts +1 -0
  38. package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.js +2 -0
  39. package/dist/_namespaces/ts.refactor.d.ts +9 -0
  40. package/dist/_namespaces/ts.refactor.extractSymbol.d.ts +1 -0
  41. package/dist/_namespaces/ts.refactor.extractSymbol.js +2 -0
  42. package/dist/_namespaces/ts.refactor.js +10 -0
  43. package/dist/_namespaces/ts.textChanges.d.ts +1 -0
  44. package/dist/_namespaces/ts.textChanges.js +2 -0
  45. package/dist/classifier.d.ts +5 -0
  46. package/dist/classifier.js +439 -0
  47. package/dist/codeFixProvider.d.ts +13 -0
  48. package/dist/codeFixProvider.js +84 -0
  49. package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.d.ts +1 -0
  50. package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.js +21 -0
  51. package/dist/codefixes/addEmptyExportDeclaration.d.ts +1 -0
  52. package/dist/codefixes/addEmptyExportDeclaration.js +17 -0
  53. package/dist/codefixes/addMissingAsync.d.ts +1 -0
  54. package/dist/codefixes/addMissingAsync.js +75 -0
  55. package/dist/codefixes/addMissingAwait.d.ts +1 -0
  56. package/dist/codefixes/addMissingAwait.js +236 -0
  57. package/dist/codefixes/addMissingConst.d.ts +1 -0
  58. package/dist/codefixes/addMissingConst.js +91 -0
  59. package/dist/codefixes/addNameToNamelessParameter.d.ts +1 -0
  60. package/dist/codefixes/addNameToNamelessParameter.js +29 -0
  61. package/dist/codefixes/convertConstToLet.d.ts +1 -0
  62. package/dist/codefixes/convertConstToLet.js +30 -0
  63. package/dist/codefixes/convertToAsyncFunction.d.ts +1 -0
  64. package/dist/codefixes/convertToAsyncFunction.js +495 -0
  65. package/dist/codefixes/convertToMappedObjectType.d.ts +1 -0
  66. package/dist/codefixes/convertToMappedObjectType.js +48 -0
  67. package/dist/codefixes/correctQualifiedNameToIndexedAccessType.d.ts +1 -0
  68. package/dist/codefixes/correctQualifiedNameToIndexedAccessType.js +33 -0
  69. package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.d.ts +1 -0
  70. package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.js +27 -0
  71. package/dist/codefixes/fixAwaitInSyncFunction.d.ts +1 -0
  72. package/dist/codefixes/fixAwaitInSyncFunction.js +69 -0
  73. package/dist/codefixes/fixExpectedComma.d.ts +1 -0
  74. package/dist/codefixes/fixExpectedComma.js +35 -0
  75. package/dist/codefixes/fixInvalidJsxCharacters.d.ts +1 -0
  76. package/dist/codefixes/fixInvalidJsxCharacters.js +41 -0
  77. package/dist/codefixes/fixMissingCallParentheses.d.ts +1 -0
  78. package/dist/codefixes/fixMissingCallParentheses.js +42 -0
  79. package/dist/codefixes/fixSpelling.d.ts +1 -0
  80. package/dist/codefixes/fixSpelling.js +94 -0
  81. package/dist/codefixes/fixUnreachableCode.d.ts +1 -0
  82. package/dist/codefixes/fixUnreachableCode.js +65 -0
  83. package/dist/codefixes/fixUnusedIdentifier.d.ts +1 -0
  84. package/dist/codefixes/fixUnusedIdentifier.js +224 -0
  85. package/dist/codefixes/helpers.d.ts +8 -0
  86. package/dist/codefixes/helpers.js +53 -0
  87. package/dist/codefixes/importFixes.d.ts +14 -0
  88. package/dist/codefixes/importFixes.js +441 -0
  89. package/dist/codefixes/inferFromUsage.d.ts +1 -0
  90. package/dist/codefixes/inferFromUsage.js +742 -0
  91. package/dist/codefixes/removeUnnecessaryAwait.d.ts +1 -0
  92. package/dist/codefixes/removeUnnecessaryAwait.js +41 -0
  93. package/dist/codefixes/returnValueCorrect.d.ts +1 -0
  94. package/dist/codefixes/returnValueCorrect.js +132 -0
  95. package/dist/codefixes/splitTypeOnlyImport.d.ts +1 -0
  96. package/dist/codefixes/splitTypeOnlyImport.js +32 -0
  97. package/dist/codefixes/useBigintLiteral.d.ts +1 -0
  98. package/dist/codefixes/useBigintLiteral.js +29 -0
  99. package/dist/completions.d.ts +83 -0
  100. package/dist/completions.js +1720 -0
  101. package/dist/documentHighlights.d.ts +8 -0
  102. package/dist/documentHighlights.js +367 -0
  103. package/dist/documentRegistry.d.ts +36 -0
  104. package/dist/documentRegistry.js +63 -0
  105. package/dist/editingServices.d.ts +1 -0
  106. package/dist/editingServices.js +4 -0
  107. package/dist/findAllReferences.d.ts +113 -0
  108. package/dist/findAllReferences.js +1366 -0
  109. package/dist/formatting/formatting.d.ts +26 -0
  110. package/dist/formatting/formatting.js +1021 -0
  111. package/dist/formatting/formattingContext.d.ts +34 -0
  112. package/dist/formatting/formattingContext.js +78 -0
  113. package/dist/formatting/formattingScanner.d.ts +14 -0
  114. package/dist/formatting/formattingScanner.js +228 -0
  115. package/dist/formatting/rule.d.ts +31 -0
  116. package/dist/formatting/rule.js +22 -0
  117. package/dist/formatting/rules.d.ts +7 -0
  118. package/dist/formatting/rules.js +610 -0
  119. package/dist/formatting/rulesMap.d.ts +5 -0
  120. package/dist/formatting/rulesMap.js +127 -0
  121. package/dist/formatting/smartIndenter.d.ts +44 -0
  122. package/dist/formatting/smartIndenter.js +518 -0
  123. package/dist/getEditsForFileRename.d.ts +6 -0
  124. package/dist/getEditsForFileRename.js +86 -0
  125. package/dist/goToDefinition.d.ts +8 -0
  126. package/dist/goToDefinition.js +246 -0
  127. package/dist/importTracker.d.ts +50 -0
  128. package/dist/importTracker.js +422 -0
  129. package/dist/index.d.ts +1 -0
  130. package/dist/index.js +3 -0
  131. package/dist/navigationBar.d.ts +3 -0
  132. package/dist/navigationBar.js +549 -0
  133. package/dist/organizeImports.d.ts +18 -0
  134. package/dist/organizeImports.js +290 -0
  135. package/dist/outliningElementsCollector.d.ts +2 -0
  136. package/dist/outliningElementsCollector.js +261 -0
  137. package/dist/refactorProvider.d.ts +5 -0
  138. package/dist/refactorProvider.js +16 -0
  139. package/dist/refactors/addOrRemoveBracesToArrowFunction.d.ts +1 -0
  140. package/dist/refactors/addOrRemoveBracesToArrowFunction.js +86 -0
  141. package/dist/refactors/convertExport.d.ts +1 -0
  142. package/dist/refactors/convertExport.js +126 -0
  143. package/dist/refactors/convertImport.d.ts +1 -0
  144. package/dist/refactors/convertImport.js +116 -0
  145. package/dist/refactors/convertParamsToDestructuredObject.d.ts +1 -0
  146. package/dist/refactors/convertParamsToDestructuredObject.js +282 -0
  147. package/dist/refactors/convertStringOrTemplateLiteral.d.ts +1 -0
  148. package/dist/refactors/convertStringOrTemplateLiteral.js +148 -0
  149. package/dist/refactors/extractSymbol.d.ts +60 -0
  150. package/dist/refactors/extractSymbol.js +1281 -0
  151. package/dist/refactors/extractType.d.ts +1 -0
  152. package/dist/refactors/extractType.js +102 -0
  153. package/dist/refactors/moveToNewFile.d.ts +1 -0
  154. package/dist/refactors/moveToNewFile.js +477 -0
  155. package/dist/rename.d.ts +2 -0
  156. package/dist/rename.js +100 -0
  157. package/dist/services.d.ts +48 -0
  158. package/dist/services.js +1480 -0
  159. package/dist/signatureHelp.d.ts +8 -0
  160. package/dist/signatureHelp.js +414 -0
  161. package/dist/smartSelection.d.ts +2 -0
  162. package/dist/smartSelection.js +243 -0
  163. package/dist/stringCompletions.d.ts +4 -0
  164. package/dist/stringCompletions.js +220 -0
  165. package/dist/suggestionDiagnostics.d.ts +6 -0
  166. package/dist/suggestionDiagnostics.js +92 -0
  167. package/dist/symbolDisplay.d.ts +16 -0
  168. package/dist/symbolDisplay.js +400 -0
  169. package/dist/textChanges.d.ts +161 -0
  170. package/dist/textChanges.js +1163 -0
  171. package/dist/types.d.ts +908 -0
  172. package/dist/types.js +263 -0
  173. package/dist/utilities.d.ts +283 -0
  174. package/dist/utilities.js +1981 -0
  175. package/package.json +45 -3
  176. package/README.md +0 -3
@@ -0,0 +1,495 @@
1
+ // Modificado de microsoft/TypeScript v3.9.10, src/services/codefixes/convertToAsyncFunction.ts: o namespace virou módulo ES, com os imports explícitos.
2
+ import { Debug, Diagnostics, NodeFlags, SyntaxKind, UnionReduction, compact, createAssignment, createAwait, createBlock, createCall, createCatchClause, createExpressionStatement, createIdentifier, createMap, createMultiMap, createOptimisticUniqueName, createReturn, createTry, createVariableDeclaration, createVariableDeclarationList, createVariableStatement, emptyArray, every, firstOrUndefined, flatMap, forEach, forEachChild, forEachReturnStatement, getContainingFunction, getNodeId, getSymbolId, getSynthesizedDeepClone, getSynthesizedDeepCloneWithRenames, getTokenAtPosition, hasPropertyAccessExpressionWithName, isBindingElement, isBlock, isCallExpression, isExpression, isFixablePromiseHandler, isFunctionLike, isFunctionLikeDeclaration, isIdentifier, isOmittedExpression, isParameter, isPropertyAccessExpression, isReturnStatement, isReturnStatementWithFixablePromiseHandler, isVariableDeclaration, lastOrUndefined, textChanges, tryCast, } from "../_namespaces/edit.js";
3
+ import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js";
4
+ const fixId = "convertToAsyncFunction";
5
+ const errorCodes = [Diagnostics.This_may_be_converted_to_an_async_function.code];
6
+ let codeActionSucceeded = true;
7
+ registerCodeFix({
8
+ errorCodes,
9
+ getCodeActions(context) {
10
+ codeActionSucceeded = true;
11
+ const changes = textChanges.ChangeTracker.with(context, (t) => convertToAsyncFunction(t, context.sourceFile, context.span.start, context.program.getTypeChecker(), context));
12
+ return codeActionSucceeded ? [createCodeFixAction(fixId, changes, Diagnostics.Convert_to_async_function, fixId, Diagnostics.Convert_all_to_async_functions)] : [];
13
+ },
14
+ fixIds: [fixId],
15
+ getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, err) => convertToAsyncFunction(changes, err.file, err.start, context.program.getTypeChecker(), context)),
16
+ });
17
+ var SynthBindingNameKind;
18
+ (function (SynthBindingNameKind) {
19
+ SynthBindingNameKind[SynthBindingNameKind["Identifier"] = 0] = "Identifier";
20
+ SynthBindingNameKind[SynthBindingNameKind["BindingPattern"] = 1] = "BindingPattern";
21
+ })(SynthBindingNameKind || (SynthBindingNameKind = {}));
22
+ function convertToAsyncFunction(changes, sourceFile, position, checker, context) {
23
+ // get the function declaration - returns a promise
24
+ const tokenAtPosition = getTokenAtPosition(sourceFile, position);
25
+ let functionToConvert;
26
+ // if the parent of a FunctionLikeDeclaration is a variable declaration, the convertToAsync diagnostic will be reported on the variable name
27
+ if (isIdentifier(tokenAtPosition) && isVariableDeclaration(tokenAtPosition.parent) &&
28
+ tokenAtPosition.parent.initializer && isFunctionLikeDeclaration(tokenAtPosition.parent.initializer)) {
29
+ functionToConvert = tokenAtPosition.parent.initializer;
30
+ }
31
+ else {
32
+ functionToConvert = tryCast(getContainingFunction(getTokenAtPosition(sourceFile, position)), isFunctionLikeDeclaration);
33
+ }
34
+ if (!functionToConvert) {
35
+ return;
36
+ }
37
+ const synthNamesMap = createMap();
38
+ const setOfExpressionsToReturn = getAllPromiseExpressionsToReturn(functionToConvert, checker);
39
+ const functionToConvertRenamed = renameCollidingVarNames(functionToConvert, checker, synthNamesMap, context.sourceFile);
40
+ const returnStatements = functionToConvertRenamed.body && isBlock(functionToConvertRenamed.body) ? getReturnStatementsWithPromiseHandlers(functionToConvertRenamed.body) : emptyArray;
41
+ const transformer = { checker, synthNamesMap, setOfExpressionsToReturn };
42
+ if (!returnStatements.length) {
43
+ return;
44
+ }
45
+ // add the async keyword
46
+ changes.insertLastModifierBefore(sourceFile, SyntaxKind.AsyncKeyword, functionToConvert);
47
+ for (const returnStatement of returnStatements) {
48
+ forEachChild(returnStatement, function visit(node) {
49
+ if (isCallExpression(node)) {
50
+ const newNodes = transformExpression(node, transformer);
51
+ changes.replaceNodeWithNodes(sourceFile, returnStatement, newNodes);
52
+ }
53
+ else if (!isFunctionLike(node)) {
54
+ forEachChild(node, visit);
55
+ }
56
+ });
57
+ }
58
+ }
59
+ function getReturnStatementsWithPromiseHandlers(body) {
60
+ const res = [];
61
+ forEachReturnStatement(body, ret => {
62
+ if (isReturnStatementWithFixablePromiseHandler(ret))
63
+ res.push(ret);
64
+ });
65
+ return res;
66
+ }
67
+ /*
68
+ Finds all of the expressions of promise type that should not be saved in a variable during the refactor
69
+ */
70
+ function getAllPromiseExpressionsToReturn(func, checker) {
71
+ if (!func.body) {
72
+ return createMap();
73
+ }
74
+ const setOfExpressionsToReturn = createMap();
75
+ forEachChild(func.body, function visit(node) {
76
+ if (isPromiseReturningCallExpression(node, checker, "then")) {
77
+ setOfExpressionsToReturn.set(getNodeId(node).toString(), true);
78
+ forEach(node.arguments, visit);
79
+ }
80
+ else if (isPromiseReturningCallExpression(node, checker, "catch")) {
81
+ setOfExpressionsToReturn.set(getNodeId(node).toString(), true);
82
+ // if .catch() is the last call in the chain, move leftward in the chain until we hit something else that should be returned
83
+ forEachChild(node, visit);
84
+ }
85
+ else if (isPromiseTypedExpression(node, checker)) {
86
+ setOfExpressionsToReturn.set(getNodeId(node).toString(), true);
87
+ // don't recurse here, since we won't refactor any children or arguments of the expression
88
+ }
89
+ else {
90
+ forEachChild(node, visit);
91
+ }
92
+ });
93
+ return setOfExpressionsToReturn;
94
+ }
95
+ function isPromiseReturningCallExpression(node, checker, name) {
96
+ if (!isCallExpression(node))
97
+ return false;
98
+ const isExpressionOfName = hasPropertyAccessExpressionWithName(node, name);
99
+ const nodeType = isExpressionOfName && checker.getTypeAtLocation(node);
100
+ return !!(nodeType && checker.getPromisedTypeOfPromise(nodeType));
101
+ }
102
+ function isPromiseTypedExpression(node, checker) {
103
+ if (!isExpression(node))
104
+ return false;
105
+ return !!checker.getPromisedTypeOfPromise(checker.getTypeAtLocation(node));
106
+ }
107
+ function declaredInFile(symbol, sourceFile) {
108
+ return symbol.valueDeclaration && symbol.valueDeclaration.getSourceFile() === sourceFile;
109
+ }
110
+ /*
111
+ Renaming of identifiers may be neccesary as the refactor changes scopes -
112
+ This function collects all existing identifier names and names of identifiers that will be created in the refactor.
113
+ It then checks for any collisions and renames them through getSynthesizedDeepClone
114
+ */
115
+ function renameCollidingVarNames(nodeToRename, checker, synthNamesMap, sourceFile) {
116
+ const identsToRenameMap = createMap(); // key is the symbol id
117
+ const collidingSymbolMap = createMultiMap();
118
+ forEachChild(nodeToRename, function visit(node) {
119
+ if (!isIdentifier(node)) {
120
+ forEachChild(node, visit);
121
+ return;
122
+ }
123
+ const symbol = checker.getSymbolAtLocation(node);
124
+ const isDefinedInFile = symbol && declaredInFile(symbol, sourceFile);
125
+ if (symbol && isDefinedInFile) {
126
+ const type = checker.getTypeAtLocation(node);
127
+ // Note - the choice of the last call signature is arbitrary
128
+ const lastCallSignature = getLastCallSignature(type, checker);
129
+ const symbolIdString = getSymbolId(symbol).toString();
130
+ // If the identifier refers to a function, we want to add the new synthesized variable for the declaration. Example:
131
+ // fetch('...').then(response => { ... })
132
+ // will eventually become
133
+ // const response = await fetch('...')
134
+ // so we push an entry for 'response'.
135
+ if (lastCallSignature && !isFunctionLikeDeclaration(node.parent) && !synthNamesMap.has(symbolIdString)) {
136
+ const firstParameter = firstOrUndefined(lastCallSignature.parameters);
137
+ const ident = firstParameter && isParameter(firstParameter.valueDeclaration) && tryCast(firstParameter.valueDeclaration.name, isIdentifier) || createOptimisticUniqueName("result");
138
+ const synthName = getNewNameIfConflict(ident, collidingSymbolMap);
139
+ synthNamesMap.set(symbolIdString, synthName);
140
+ collidingSymbolMap.add(ident.text, symbol);
141
+ }
142
+ // We only care about identifiers that are parameters, variable declarations, or binding elements
143
+ else if (node.parent && (isParameter(node.parent) || isVariableDeclaration(node.parent) || isBindingElement(node.parent))) {
144
+ const originalName = node.text;
145
+ const collidingSymbols = collidingSymbolMap.get(originalName);
146
+ // if the identifier name conflicts with a different identifier that we've already seen
147
+ if (collidingSymbols && collidingSymbols.some(prevSymbol => prevSymbol !== symbol)) {
148
+ const newName = getNewNameIfConflict(node, collidingSymbolMap);
149
+ identsToRenameMap.set(symbolIdString, newName.identifier);
150
+ synthNamesMap.set(symbolIdString, newName);
151
+ collidingSymbolMap.add(originalName, symbol);
152
+ }
153
+ else {
154
+ const identifier = getSynthesizedDeepClone(node);
155
+ synthNamesMap.set(symbolIdString, createSynthIdentifier(identifier));
156
+ collidingSymbolMap.add(originalName, symbol);
157
+ }
158
+ }
159
+ }
160
+ });
161
+ return getSynthesizedDeepCloneWithRenames(nodeToRename, /*includeTrivia*/ true, identsToRenameMap, checker);
162
+ }
163
+ function getNewNameIfConflict(name, originalNames) {
164
+ const numVarsSameName = (originalNames.get(name.text) || emptyArray).length;
165
+ const identifier = numVarsSameName === 0 ? name : createIdentifier(name.text + "_" + numVarsSameName);
166
+ return createSynthIdentifier(identifier);
167
+ }
168
+ function silentFail() {
169
+ codeActionSucceeded = false;
170
+ return emptyArray;
171
+ }
172
+ // dispatch function to recursively build the refactoring
173
+ // should be kept up to date with isFixablePromiseHandler in suggestionDiagnostics.ts
174
+ function transformExpression(node, transformer, prevArgName) {
175
+ if (isPromiseReturningCallExpression(node, transformer.checker, "then")) {
176
+ if (node.arguments.length === 0)
177
+ return silentFail();
178
+ return transformThen(node, transformer, prevArgName);
179
+ }
180
+ if (isPromiseReturningCallExpression(node, transformer.checker, "catch")) {
181
+ if (node.arguments.length === 0)
182
+ return silentFail();
183
+ return transformCatch(node, transformer, prevArgName);
184
+ }
185
+ if (isPropertyAccessExpression(node)) {
186
+ return transformExpression(node.expression, transformer, prevArgName);
187
+ }
188
+ const nodeType = transformer.checker.getTypeAtLocation(node);
189
+ if (nodeType && transformer.checker.getPromisedTypeOfPromise(nodeType)) {
190
+ Debug.assertNode(node.original.parent, isPropertyAccessExpression);
191
+ return transformPromiseExpressionOfPropertyAccess(node, transformer, prevArgName);
192
+ }
193
+ return silentFail();
194
+ }
195
+ function transformCatch(node, transformer, prevArgName) {
196
+ const func = node.arguments[0];
197
+ const argName = getArgBindingName(func, transformer);
198
+ let possibleNameForVarDecl;
199
+ /*
200
+ If there is another call in the chain after the .catch() we are transforming, we will need to save the result of both paths (try block and catch block)
201
+ To do this, we will need to synthesize a variable that we were not aware of while we were adding identifiers to the synthNamesMap
202
+ We will use the prevArgName and then update the synthNamesMap with a new variable name for the next transformation step
203
+ */
204
+ if (prevArgName && !shouldReturn(node, transformer)) {
205
+ if (isSynthIdentifier(prevArgName)) {
206
+ possibleNameForVarDecl = prevArgName;
207
+ transformer.synthNamesMap.forEach((val, key) => {
208
+ if (val.identifier.text === prevArgName.identifier.text) {
209
+ const newSynthName = createUniqueSynthName(prevArgName);
210
+ transformer.synthNamesMap.set(key, newSynthName);
211
+ }
212
+ });
213
+ }
214
+ else {
215
+ possibleNameForVarDecl = createSynthIdentifier(createOptimisticUniqueName("result"), prevArgName.types);
216
+ }
217
+ // We are about to write a 'let' variable declaration, but `transformExpression` for both
218
+ // the try block and catch block will assign to this name. Setting this flag indicates
219
+ // that future assignments should be written as `name = value` instead of `const name = value`.
220
+ possibleNameForVarDecl.hasBeenDeclared = true;
221
+ }
222
+ const tryBlock = createBlock(transformExpression(node.expression, transformer, possibleNameForVarDecl));
223
+ const transformationBody = getTransformationBody(func, possibleNameForVarDecl, argName, node, transformer);
224
+ const catchArg = argName ? isSynthIdentifier(argName) ? argName.identifier.text : argName.bindingPattern : "e";
225
+ const catchVariableDeclaration = createVariableDeclaration(catchArg);
226
+ const catchClause = createCatchClause(catchVariableDeclaration, createBlock(transformationBody));
227
+ /*
228
+ In order to avoid an implicit any, we will synthesize a type for the declaration using the unions of the types of both paths (try block and catch block)
229
+ */
230
+ let varDeclList;
231
+ let varDeclIdentifier;
232
+ if (possibleNameForVarDecl && !shouldReturn(node, transformer)) {
233
+ varDeclIdentifier = getSynthesizedDeepClone(possibleNameForVarDecl.identifier);
234
+ const typeArray = possibleNameForVarDecl.types;
235
+ const unionType = transformer.checker.getUnionType(typeArray, UnionReduction.Subtype);
236
+ const unionTypeNode = transformer.checker.typeToTypeNode(unionType, /*enclosingDeclaration*/ undefined, /*flags*/ undefined);
237
+ const varDecl = [createVariableDeclaration(varDeclIdentifier, unionTypeNode)];
238
+ varDeclList = createVariableStatement(/*modifiers*/ undefined, createVariableDeclarationList(varDecl, NodeFlags.Let));
239
+ }
240
+ const tryStatement = createTry(tryBlock, catchClause, /*finallyBlock*/ undefined);
241
+ const destructuredResult = prevArgName && varDeclIdentifier && isSynthBindingPattern(prevArgName)
242
+ && createVariableStatement(/* modifiers */ undefined, createVariableDeclarationList([createVariableDeclaration(getSynthesizedDeepCloneWithRenames(prevArgName.bindingPattern), /* type */ undefined, varDeclIdentifier)], NodeFlags.Const));
243
+ return compact([varDeclList, tryStatement, destructuredResult]);
244
+ }
245
+ function createUniqueSynthName(prevArgName) {
246
+ const renamedPrevArg = createOptimisticUniqueName(prevArgName.identifier.text);
247
+ return createSynthIdentifier(renamedPrevArg);
248
+ }
249
+ function transformThen(node, transformer, prevArgName) {
250
+ const [onFulfilled, onRejected] = node.arguments;
251
+ const onFulfilledArgumentName = getArgBindingName(onFulfilled, transformer);
252
+ const transformationBody = getTransformationBody(onFulfilled, prevArgName, onFulfilledArgumentName, node, transformer);
253
+ if (onRejected) {
254
+ const onRejectedArgumentName = getArgBindingName(onRejected, transformer);
255
+ const tryBlock = createBlock(transformExpression(node.expression, transformer, onFulfilledArgumentName).concat(transformationBody));
256
+ const transformationBody2 = getTransformationBody(onRejected, prevArgName, onRejectedArgumentName, node, transformer);
257
+ const catchArg = onRejectedArgumentName ? isSynthIdentifier(onRejectedArgumentName) ? onRejectedArgumentName.identifier.text : onRejectedArgumentName.bindingPattern : "e";
258
+ const catchVariableDeclaration = createVariableDeclaration(catchArg);
259
+ const catchClause = createCatchClause(catchVariableDeclaration, createBlock(transformationBody2));
260
+ return [createTry(tryBlock, catchClause, /* finallyBlock */ undefined)];
261
+ }
262
+ return transformExpression(node.expression, transformer, onFulfilledArgumentName).concat(transformationBody);
263
+ }
264
+ /**
265
+ * Transforms the 'x' part of `x.then(...)`, or the 'y()' part of `y().catch(...)`, where 'x' and 'y()' are Promises.
266
+ */
267
+ function transformPromiseExpressionOfPropertyAccess(node, transformer, prevArgName) {
268
+ if (shouldReturn(node, transformer)) {
269
+ return [createReturn(getSynthesizedDeepClone(node))];
270
+ }
271
+ return createVariableOrAssignmentOrExpressionStatement(prevArgName, createAwait(node), /*typeAnnotation*/ undefined);
272
+ }
273
+ function createVariableOrAssignmentOrExpressionStatement(variableName, rightHandSide, typeAnnotation) {
274
+ if (!variableName || isEmptyBindingName(variableName)) {
275
+ // if there's no argName to assign to, there still might be side effects
276
+ return [createExpressionStatement(rightHandSide)];
277
+ }
278
+ if (isSynthIdentifier(variableName) && variableName.hasBeenDeclared) {
279
+ // if the variable has already been declared, we don't need "let" or "const"
280
+ return [createExpressionStatement(createAssignment(getSynthesizedDeepClone(variableName.identifier), rightHandSide))];
281
+ }
282
+ return [
283
+ createVariableStatement(
284
+ /*modifiers*/ undefined, createVariableDeclarationList([
285
+ createVariableDeclaration(getSynthesizedDeepClone(getNode(variableName)), typeAnnotation, rightHandSide)
286
+ ], NodeFlags.Const))
287
+ ];
288
+ }
289
+ function maybeAnnotateAndReturn(expressionToReturn, typeAnnotation) {
290
+ if (typeAnnotation && expressionToReturn) {
291
+ const name = createOptimisticUniqueName("result");
292
+ return [
293
+ ...createVariableOrAssignmentOrExpressionStatement(createSynthIdentifier(name), expressionToReturn, typeAnnotation),
294
+ createReturn(name)
295
+ ];
296
+ }
297
+ return [createReturn(expressionToReturn)];
298
+ }
299
+ // should be kept up to date with isFixablePromiseArgument in suggestionDiagnostics.ts
300
+ function getTransformationBody(func, prevArgName, argName, parent, transformer) {
301
+ switch (func.kind) {
302
+ case SyntaxKind.NullKeyword:
303
+ // do not produce a transformed statement for a null argument
304
+ break;
305
+ case SyntaxKind.Identifier: // identifier includes undefined
306
+ if (!argName) {
307
+ // undefined was argument passed to promise handler
308
+ break;
309
+ }
310
+ const synthCall = createCall(getSynthesizedDeepClone(func), /*typeArguments*/ undefined, isSynthIdentifier(argName) ? [argName.identifier] : []);
311
+ if (shouldReturn(parent, transformer)) {
312
+ return maybeAnnotateAndReturn(synthCall, parent.typeArguments?.[0]);
313
+ }
314
+ const type = transformer.checker.getTypeAtLocation(func);
315
+ const callSignatures = transformer.checker.getSignaturesOfType(type);
316
+ if (!callSignatures.length) {
317
+ // if identifier in handler has no call signatures, it's invalid
318
+ return silentFail();
319
+ }
320
+ const returnType = callSignatures[0].getReturnType();
321
+ const varDeclOrAssignment = createVariableOrAssignmentOrExpressionStatement(prevArgName, createAwait(synthCall), parent.typeArguments?.[0]);
322
+ if (prevArgName) {
323
+ prevArgName.types.push(returnType);
324
+ }
325
+ return varDeclOrAssignment;
326
+ // Na tag, também a function expression (CK-02).
327
+ case SyntaxKind.ArrowFunction: {
328
+ const funcBody = func.body;
329
+ // Arrow functions with block bodies { } will enter this control flow
330
+ if (isBlock(funcBody)) {
331
+ let refactoredStmts = [];
332
+ let seenReturnStatement = false;
333
+ for (const statement of funcBody.statements) {
334
+ if (isReturnStatement(statement)) {
335
+ seenReturnStatement = true;
336
+ if (isReturnStatementWithFixablePromiseHandler(statement)) {
337
+ refactoredStmts = refactoredStmts.concat(getInnerTransformationBody(transformer, [statement], prevArgName));
338
+ }
339
+ else {
340
+ refactoredStmts.push(...maybeAnnotateAndReturn(statement.expression, parent.typeArguments?.[0]));
341
+ }
342
+ }
343
+ else {
344
+ refactoredStmts.push(statement);
345
+ }
346
+ }
347
+ return shouldReturn(parent, transformer)
348
+ ? refactoredStmts.map(s => getSynthesizedDeepClone(s))
349
+ : removeReturns(refactoredStmts, prevArgName, transformer, seenReturnStatement);
350
+ }
351
+ else {
352
+ const innerRetStmts = isFixablePromiseHandler(funcBody) ? [createReturn(funcBody)] : emptyArray;
353
+ const innerCbBody = getInnerTransformationBody(transformer, innerRetStmts, prevArgName);
354
+ if (innerCbBody.length > 0) {
355
+ return innerCbBody;
356
+ }
357
+ const type = transformer.checker.getTypeAtLocation(func);
358
+ const returnType = getLastCallSignature(type, transformer.checker).getReturnType();
359
+ const rightHandSide = getSynthesizedDeepClone(funcBody);
360
+ const possiblyAwaitedRightHandSide = !!transformer.checker.getPromisedTypeOfPromise(returnType) ? createAwait(rightHandSide) : rightHandSide;
361
+ if (!shouldReturn(parent, transformer)) {
362
+ const transformedStatement = createVariableOrAssignmentOrExpressionStatement(prevArgName, possiblyAwaitedRightHandSide, /*typeAnnotation*/ undefined);
363
+ if (prevArgName) {
364
+ prevArgName.types.push(returnType);
365
+ }
366
+ return transformedStatement;
367
+ }
368
+ else {
369
+ return maybeAnnotateAndReturn(possiblyAwaitedRightHandSide, parent.typeArguments?.[0]);
370
+ }
371
+ }
372
+ }
373
+ default:
374
+ // If no cases apply, we've found a transformation body we don't know how to handle, so the refactoring should no-op to avoid deleting code.
375
+ return silentFail();
376
+ }
377
+ return emptyArray;
378
+ }
379
+ function getLastCallSignature(type, checker) {
380
+ const callSignatures = checker.getSignaturesOfType(type);
381
+ return lastOrUndefined(callSignatures);
382
+ }
383
+ function removeReturns(stmts, prevArgName, transformer, seenReturnStatement) {
384
+ const ret = [];
385
+ for (const stmt of stmts) {
386
+ if (isReturnStatement(stmt)) {
387
+ if (stmt.expression) {
388
+ const possiblyAwaitedExpression = isPromiseTypedExpression(stmt.expression, transformer.checker) ? createAwait(stmt.expression) : stmt.expression;
389
+ if (prevArgName === undefined) {
390
+ ret.push(createExpressionStatement(possiblyAwaitedExpression));
391
+ }
392
+ else {
393
+ ret.push(createVariableStatement(/*modifiers*/ undefined, (createVariableDeclarationList([createVariableDeclaration(getNode(prevArgName), /*type*/ undefined, possiblyAwaitedExpression)], NodeFlags.Const))));
394
+ }
395
+ }
396
+ }
397
+ else {
398
+ ret.push(getSynthesizedDeepClone(stmt));
399
+ }
400
+ }
401
+ // if block has no return statement, need to define prevArgName as undefined to prevent undeclared variables
402
+ if (!seenReturnStatement && prevArgName !== undefined) {
403
+ ret.push(createVariableStatement(/*modifiers*/ undefined, (createVariableDeclarationList([createVariableDeclaration(getNode(prevArgName), /*type*/ undefined, createIdentifier("undefined"))], NodeFlags.Const))));
404
+ }
405
+ return ret;
406
+ }
407
+ function getInnerTransformationBody(transformer, innerRetStmts, prevArgName) {
408
+ let innerCbBody = [];
409
+ for (const stmt of innerRetStmts) {
410
+ forEachChild(stmt, function visit(node) {
411
+ if (isCallExpression(node)) {
412
+ const temp = transformExpression(node, transformer, prevArgName);
413
+ innerCbBody = innerCbBody.concat(temp);
414
+ if (innerCbBody.length > 0) {
415
+ return;
416
+ }
417
+ }
418
+ else if (!isFunctionLike(node)) {
419
+ forEachChild(node, visit);
420
+ }
421
+ });
422
+ }
423
+ return innerCbBody;
424
+ }
425
+ function getArgBindingName(funcNode, transformer) {
426
+ const types = [];
427
+ let name;
428
+ if (isFunctionLikeDeclaration(funcNode)) {
429
+ if (funcNode.parameters.length > 0) {
430
+ const param = funcNode.parameters[0].name;
431
+ name = getMappedBindingNameOrDefault(param);
432
+ }
433
+ }
434
+ else if (isIdentifier(funcNode)) {
435
+ name = getMapEntryOrDefault(funcNode);
436
+ }
437
+ // return undefined argName when arg is null or undefined
438
+ // eslint-disable-next-line no-in-operator
439
+ if (!name || "identifier" in name && name.identifier.text === "undefined") {
440
+ return undefined;
441
+ }
442
+ return name;
443
+ function getMappedBindingNameOrDefault(bindingName) {
444
+ if (isIdentifier(bindingName))
445
+ return getMapEntryOrDefault(bindingName);
446
+ const elements = flatMap(bindingName.elements, element => {
447
+ if (isOmittedExpression(element))
448
+ return [];
449
+ return [getMappedBindingNameOrDefault(element.name)];
450
+ });
451
+ return createSynthBindingPattern(bindingName, elements);
452
+ }
453
+ function getMapEntryOrDefault(identifier) {
454
+ const originalNode = getOriginalNode(identifier);
455
+ const symbol = getSymbol(originalNode);
456
+ if (!symbol) {
457
+ return createSynthIdentifier(identifier, types);
458
+ }
459
+ const mapEntry = transformer.synthNamesMap.get(getSymbolId(symbol).toString());
460
+ return mapEntry || createSynthIdentifier(identifier, types);
461
+ }
462
+ function getSymbol(node) {
463
+ return node.symbol ? node.symbol : transformer.checker.getSymbolAtLocation(node);
464
+ }
465
+ function getOriginalNode(node) {
466
+ return node.original ? node.original : node;
467
+ }
468
+ }
469
+ function isEmptyBindingName(bindingName) {
470
+ if (!bindingName) {
471
+ return true;
472
+ }
473
+ if (isSynthIdentifier(bindingName)) {
474
+ return !bindingName.identifier.text;
475
+ }
476
+ return every(bindingName.elements, isEmptyBindingName);
477
+ }
478
+ function getNode(bindingName) {
479
+ return isSynthIdentifier(bindingName) ? bindingName.identifier : bindingName.bindingPattern;
480
+ }
481
+ function createSynthIdentifier(identifier, types = []) {
482
+ return { kind: 0 /* SynthBindingNameKind.Identifier */, identifier, types, hasBeenDeclared: false };
483
+ }
484
+ function createSynthBindingPattern(bindingPattern, elements = emptyArray, types = []) {
485
+ return { kind: 1 /* SynthBindingNameKind.BindingPattern */, bindingPattern, elements, types };
486
+ }
487
+ function isSynthIdentifier(bindingName) {
488
+ return bindingName.kind === 0 /* SynthBindingNameKind.Identifier */;
489
+ }
490
+ function isSynthBindingPattern(bindingName) {
491
+ return bindingName.kind === 1 /* SynthBindingNameKind.BindingPattern */;
492
+ }
493
+ function shouldReturn(expression, transformer) {
494
+ return !!expression.original && transformer.setOfExpressionsToReturn.has(getNodeId(expression.original).toString());
495
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ // Modificado de microsoft/TypeScript v3.9.10, src/services/codefixes/convertToMappedObjectType.ts: o namespace virou módulo ES, com os imports explícitos.
2
+ import { Diagnostics, SyntaxKind, cast, createIntersectionTypeNode, createMappedTypeNode, createModifier, createTypeAliasDeclaration, createTypeLiteralNode, createTypeParameterDeclaration, emptyArray, first, getTokenAtPosition, hasReadonlyModifier, idText, isIdentifier, isIndexSignatureDeclaration, isTypeAliasDeclaration, textChanges, } from "../_namespaces/edit.js";
3
+ import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js";
4
+ const fixIdAddMissingTypeof = "fixConvertToMappedObjectType";
5
+ const fixId = fixIdAddMissingTypeof;
6
+ const errorCodes = [Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead.code];
7
+ registerCodeFix({
8
+ errorCodes,
9
+ getCodeActions: context => {
10
+ const { sourceFile, span } = context;
11
+ const info = getInfo(sourceFile, span.start);
12
+ if (!info)
13
+ return undefined;
14
+ const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, info));
15
+ const name = idText(info.container.name);
16
+ return [createCodeFixAction(fixId, changes, [Diagnostics.Convert_0_to_mapped_object_type, name], fixId, [Diagnostics.Convert_0_to_mapped_object_type, name])];
17
+ },
18
+ fixIds: [fixId],
19
+ getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => {
20
+ const info = getInfo(diag.file, diag.start);
21
+ if (info)
22
+ doChange(changes, diag.file, info);
23
+ })
24
+ });
25
+ function getInfo(sourceFile, pos) {
26
+ const token = getTokenAtPosition(sourceFile, pos);
27
+ const indexSignature = cast(token.parent.parent, isIndexSignatureDeclaration);
28
+ // Na tag, a index signature de uma classe não se convertia, e a de uma `interface` convertia a interface (CK-02).
29
+ const container = cast(indexSignature.parent.parent, isTypeAliasDeclaration);
30
+ return { indexSignature, container };
31
+ }
32
+ function createTypeAliasFromInterface(declaration, type) {
33
+ return createTypeAliasDeclaration(declaration.modifiers, declaration.name, declaration.typeParameters, type);
34
+ }
35
+ function doChange(changes, sourceFile, { indexSignature, container }) {
36
+ // Na tag, também os membros de uma `interface` (CK-02).
37
+ const members = container.type.members;
38
+ const otherMembers = members.filter(member => !isIndexSignatureDeclaration(member));
39
+ const parameter = first(indexSignature.parameters);
40
+ const mappedTypeParameter = createTypeParameterDeclaration(cast(parameter.name, isIdentifier), parameter.type);
41
+ const mappedIntersectionType = createMappedTypeNode(hasReadonlyModifier(indexSignature) ? createModifier(SyntaxKind.ReadonlyKeyword) : undefined, mappedTypeParameter, indexSignature.questionToken, indexSignature.type);
42
+ const intersectionType = createIntersectionTypeNode([
43
+ // Na tag, primeiro os tipos que uma `interface` estendia (CK-02).
44
+ mappedIntersectionType,
45
+ ...(otherMembers.length ? [createTypeLiteralNode(otherMembers)] : emptyArray),
46
+ ]);
47
+ changes.replaceNode(sourceFile, container, createTypeAliasFromInterface(container, intersectionType));
48
+ }
@@ -0,0 +1,33 @@
1
+ // Modificado de microsoft/TypeScript v3.9.10, src/services/codefixes/correctQualifiedNameToIndexedAccessType.ts: o namespace virou módulo ES, com os imports explícitos.
2
+ import { Debug, Diagnostics, createIndexedAccessTypeNode, createLiteral, createLiteralTypeNode, createTypeReferenceNode, findAncestor, getTokenAtPosition, isIdentifier, isQualifiedName, textChanges, } from "../_namespaces/edit.js";
3
+ import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js";
4
+ const fixId = "correctQualifiedNameToIndexedAccessType";
5
+ const errorCodes = [Diagnostics.Cannot_access_0_1_because_0_is_a_type_but_not_a_namespace_Did_you_mean_to_retrieve_the_type_of_the_property_1_in_0_with_0_1.code];
6
+ registerCodeFix({
7
+ errorCodes,
8
+ getCodeActions(context) {
9
+ const qualifiedName = getQualifiedName(context.sourceFile, context.span.start);
10
+ if (!qualifiedName)
11
+ return undefined;
12
+ const changes = textChanges.ChangeTracker.with(context, t => doChange(t, context.sourceFile, qualifiedName));
13
+ const newText = `${qualifiedName.left.text}["${qualifiedName.right.text}"]`;
14
+ return [createCodeFixAction(fixId, changes, [Diagnostics.Rewrite_as_the_indexed_access_type_0, newText], fixId, Diagnostics.Rewrite_all_as_indexed_access_types)];
15
+ },
16
+ fixIds: [fixId],
17
+ getAllCodeActions: (context) => codeFixAll(context, errorCodes, (changes, diag) => {
18
+ const q = getQualifiedName(diag.file, diag.start);
19
+ if (q) {
20
+ doChange(changes, diag.file, q);
21
+ }
22
+ }),
23
+ });
24
+ function getQualifiedName(sourceFile, pos) {
25
+ const qualifiedName = findAncestor(getTokenAtPosition(sourceFile, pos), isQualifiedName);
26
+ Debug.assert(!!qualifiedName, "Expected position to be owned by a qualified name.");
27
+ return isIdentifier(qualifiedName.left) ? qualifiedName : undefined;
28
+ }
29
+ function doChange(changeTracker, sourceFile, qualifiedName) {
30
+ const rightText = qualifiedName.right.text;
31
+ const replacement = createIndexedAccessTypeNode(createTypeReferenceNode(qualifiedName.left, /*typeArguments*/ undefined), createLiteralTypeNode(createLiteral(rightText)));
32
+ changeTracker.replaceNode(sourceFile, qualifiedName, replacement);
33
+ }
@@ -0,0 +1,27 @@
1
+ // Modificado de microsoft/TypeScript v3.9.10, src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts: o namespace virou módulo ES, com os imports explícitos.
2
+ import { Debug, Diagnostics, SyntaxKind, getTokenAtPosition, textChanges, updateImportTypeNode, } from "../_namespaces/edit.js";
3
+ import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js";
4
+ const fixIdAddMissingTypeof = "fixAddModuleReferTypeMissingTypeof";
5
+ const fixId = fixIdAddMissingTypeof;
6
+ const errorCodes = [Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0.code];
7
+ registerCodeFix({
8
+ errorCodes,
9
+ getCodeActions: context => {
10
+ const { sourceFile, span } = context;
11
+ const importType = getImportTypeNode(sourceFile, span.start);
12
+ const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, importType));
13
+ return [createCodeFixAction(fixId, changes, Diagnostics.Add_missing_typeof, fixId, Diagnostics.Add_missing_typeof)];
14
+ },
15
+ fixIds: [fixId],
16
+ getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => doChange(changes, context.sourceFile, getImportTypeNode(diag.file, diag.start))),
17
+ });
18
+ function getImportTypeNode(sourceFile, pos) {
19
+ const token = getTokenAtPosition(sourceFile, pos);
20
+ Debug.assert(token.kind === SyntaxKind.ImportKeyword, "This token should be an ImportKeyword");
21
+ Debug.assert(token.parent.kind === SyntaxKind.ImportType, "Token parent should be an ImportType");
22
+ return token.parent;
23
+ }
24
+ function doChange(changes, sourceFile, importType) {
25
+ const newTypeNode = updateImportTypeNode(importType, importType.argument, importType.qualifier, importType.typeArguments, /* isTypeOf */ true);
26
+ changes.replaceNode(sourceFile, importType, newTypeNode);
27
+ }
@@ -0,0 +1 @@
1
+ export {};