@tslite/services 1.16.0 → 1.17.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.
- package/NOTICE +3 -1
- package/dist/_namespaces/edit.d.ts +1 -1
- package/dist/_namespaces/edit.js +10759 -11
- package/dist/_namespaces/ts.codefix.d.ts +0 -1
- package/dist/_namespaces/ts.js +10196 -19
- package/dist/classifier.d.ts +3 -1
- package/dist/codeFixProvider.d.ts +2 -1
- package/dist/codefixes/helpers.d.ts +3 -1
- package/dist/codefixes/importFixes.d.ts +3 -1
- package/dist/completions.d.ts +5 -2
- package/dist/documentHighlights.d.ts +3 -1
- package/dist/documentRegistry.d.ts +2 -1
- package/dist/findAllReferences.d.ts +3 -1
- package/dist/formatting/formatting.d.ts +3 -2
- package/dist/formatting/formattingContext.d.ts +2 -1
- package/dist/formatting/formattingScanner.d.ts +2 -2
- package/dist/formatting/rule.d.ts +1 -1
- package/dist/formatting/rulesMap.d.ts +1 -1
- package/dist/formatting/smartIndenter.d.ts +2 -1
- package/dist/getEditsForFileRename.d.ts +4 -1
- package/dist/goToDefinition.d.ts +3 -1
- package/dist/importTracker.d.ts +2 -1
- package/dist/navigationBar.d.ts +3 -1
- package/dist/organizeImports.d.ts +4 -2
- package/dist/outliningElementsCollector.d.ts +3 -1
- package/dist/refactorProvider.d.ts +1 -1
- package/dist/refactors/extractSymbol.d.ts +2 -1
- package/dist/rename.d.ts +3 -1
- package/dist/services.d.ts +5 -2
- package/dist/signatureHelp.d.ts +3 -1
- package/dist/smartSelection.d.ts +2 -1
- package/dist/stringCompletions.d.ts +3 -1
- package/dist/suggestionDiagnostics.d.ts +4 -3
- package/dist/symbolDisplay.d.ts +3 -1
- package/dist/textChanges.d.ts +4 -2
- package/dist/types.d.ts +3 -3
- package/dist/utilities.d.ts +7 -2
- package/package.json +7 -5
- package/dist/_namespaces/ts.Completions.StringCompletions.js +0 -2
- package/dist/_namespaces/ts.Completions.js +0 -3
- package/dist/_namespaces/ts.FindAllReferences.js +0 -3
- package/dist/_namespaces/ts.GoToDefinition.js +0 -2
- package/dist/_namespaces/ts.NavigationBar.js +0 -2
- package/dist/_namespaces/ts.OrganizeImports.js +0 -2
- package/dist/_namespaces/ts.OutliningElementsCollector.js +0 -2
- package/dist/_namespaces/ts.Rename.js +0 -2
- package/dist/_namespaces/ts.SignatureHelp.js +0 -2
- package/dist/_namespaces/ts.SmartSelectionRange.js +0 -2
- package/dist/_namespaces/ts.SymbolDisplay.js +0 -2
- package/dist/_namespaces/ts.codefix.js +0 -27
- package/dist/_namespaces/ts.formatting.js +0 -8
- package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.js +0 -2
- package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.js +0 -2
- package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.js +0 -2
- package/dist/_namespaces/ts.refactor.extractSymbol.js +0 -2
- package/dist/_namespaces/ts.refactor.js +0 -10
- package/dist/_namespaces/ts.textChanges.js +0 -2
- package/dist/classifier.js +0 -715
- package/dist/codeFixProvider.js +0 -84
- package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.d.ts +0 -1
- package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.js +0 -21
- package/dist/codefixes/addEmptyExportDeclaration.js +0 -17
- package/dist/codefixes/addMissingAsync.js +0 -75
- package/dist/codefixes/addMissingAwait.js +0 -236
- package/dist/codefixes/addMissingConst.js +0 -91
- package/dist/codefixes/addNameToNamelessParameter.js +0 -29
- package/dist/codefixes/convertConstToLet.js +0 -30
- package/dist/codefixes/convertToAsyncFunction.js +0 -495
- package/dist/codefixes/convertToMappedObjectType.js +0 -48
- package/dist/codefixes/correctQualifiedNameToIndexedAccessType.js +0 -33
- package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.js +0 -27
- package/dist/codefixes/fixAwaitInSyncFunction.js +0 -69
- package/dist/codefixes/fixExpectedComma.js +0 -35
- package/dist/codefixes/fixInvalidJsxCharacters.js +0 -41
- package/dist/codefixes/fixMissingCallParentheses.js +0 -42
- package/dist/codefixes/fixSpelling.js +0 -94
- package/dist/codefixes/fixUnreachableCode.js +0 -65
- package/dist/codefixes/fixUnusedIdentifier.js +0 -224
- package/dist/codefixes/helpers.js +0 -53
- package/dist/codefixes/importFixes.js +0 -441
- package/dist/codefixes/inferFromUsage.js +0 -742
- package/dist/codefixes/removeUnnecessaryAwait.js +0 -41
- package/dist/codefixes/returnValueCorrect.js +0 -132
- package/dist/codefixes/splitTypeOnlyImport.js +0 -32
- package/dist/codefixes/useBigintLiteral.js +0 -29
- package/dist/completions.js +0 -1720
- package/dist/documentHighlights.js +0 -367
- package/dist/documentRegistry.js +0 -63
- package/dist/editingServices.js +0 -4
- package/dist/findAllReferences.js +0 -1366
- package/dist/formatting/formatting.js +0 -1021
- package/dist/formatting/formattingContext.js +0 -78
- package/dist/formatting/formattingScanner.js +0 -228
- package/dist/formatting/rule.js +0 -22
- package/dist/formatting/rules.js +0 -610
- package/dist/formatting/rulesMap.js +0 -127
- package/dist/formatting/smartIndenter.js +0 -518
- package/dist/getEditsForFileRename.js +0 -86
- package/dist/goToDefinition.js +0 -246
- package/dist/importTracker.js +0 -422
- package/dist/index.js +0 -3
- package/dist/navigationBar.js +0 -549
- package/dist/organizeImports.js +0 -290
- package/dist/outliningElementsCollector.js +0 -261
- package/dist/refactorProvider.js +0 -16
- package/dist/refactors/addOrRemoveBracesToArrowFunction.js +0 -86
- package/dist/refactors/convertExport.js +0 -126
- package/dist/refactors/convertImport.js +0 -116
- package/dist/refactors/convertParamsToDestructuredObject.js +0 -282
- package/dist/refactors/convertStringOrTemplateLiteral.js +0 -148
- package/dist/refactors/extractSymbol.js +0 -1281
- package/dist/refactors/extractType.js +0 -102
- package/dist/refactors/moveToNewFile.js +0 -477
- package/dist/rename.js +0 -100
- package/dist/services.js +0 -1480
- package/dist/signatureHelp.js +0 -414
- package/dist/smartSelection.js +0 -243
- package/dist/stringCompletions.js +0 -220
- package/dist/suggestionDiagnostics.js +0 -92
- package/dist/symbolDisplay.js +0 -400
- package/dist/textChanges.js +0 -1163
- package/dist/types.js +0 -263
- package/dist/utilities.js +0 -1981
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// Modificado de microsoft/TypeScript v3.9.10, src/services/codefixes/removeUnnecessaryAwait.ts: o namespace virou módulo ES, com os imports explícitos.
|
|
2
|
-
import { Diagnostics, SyntaxKind, findPrecedingToken, getLeftmostExpression, getTokenAtPosition, isAwaitExpression, isIdentifier, isParenthesizedExpression, textChanges, tryCast, } from "../_namespaces/edit.js";
|
|
3
|
-
import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js";
|
|
4
|
-
const fixId = "removeUnnecessaryAwait";
|
|
5
|
-
const errorCodes = [
|
|
6
|
-
Diagnostics.await_has_no_effect_on_the_type_of_this_expression.code,
|
|
7
|
-
];
|
|
8
|
-
registerCodeFix({
|
|
9
|
-
errorCodes,
|
|
10
|
-
getCodeActions: (context) => {
|
|
11
|
-
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span));
|
|
12
|
-
if (changes.length > 0) {
|
|
13
|
-
return [createCodeFixAction(fixId, changes, Diagnostics.Remove_unnecessary_await, fixId, Diagnostics.Remove_all_unnecessary_uses_of_await)];
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
fixIds: [fixId],
|
|
17
|
-
getAllCodeActions: context => {
|
|
18
|
-
return codeFixAll(context, errorCodes, (changes, diag) => makeChange(changes, diag.file, diag));
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
function makeChange(changeTracker, sourceFile, span) {
|
|
22
|
-
const awaitKeyword = tryCast(getTokenAtPosition(sourceFile, span.start), (node) => node.kind === SyntaxKind.AwaitKeyword);
|
|
23
|
-
const awaitExpression = awaitKeyword && tryCast(awaitKeyword.parent, isAwaitExpression);
|
|
24
|
-
if (!awaitExpression) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
let expressionToReplace = awaitExpression;
|
|
28
|
-
const hasSurroundingParens = isParenthesizedExpression(awaitExpression.parent);
|
|
29
|
-
if (hasSurroundingParens) {
|
|
30
|
-
// Na tag, com o `stopAtCallExpressions` desligado, que a cópia tirou porque todo chamador o desligava.
|
|
31
|
-
const leftMostExpression = getLeftmostExpression(awaitExpression.expression);
|
|
32
|
-
if (isIdentifier(leftMostExpression)) {
|
|
33
|
-
const precedingToken = findPrecedingToken(awaitExpression.parent.pos, sourceFile);
|
|
34
|
-
// Na tag, o `new (await x)()` ficava com os parênteses; o `new` saiu (CK-02, CK-56).
|
|
35
|
-
if (precedingToken) {
|
|
36
|
-
expressionToReplace = awaitExpression.parent;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
changeTracker.replaceNode(sourceFile, expressionToReplace, awaitExpression.expression);
|
|
41
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
// Modificado de microsoft/TypeScript v3.9.10, src/services/codefixes/returnValueCorrect.ts: o namespace virou módulo ES, com os imports explícitos.
|
|
2
|
-
import { Debug, Diagnostics, SyntaxKind, append, copyComments, createBlock, createParen, createReturn, findAncestor, first, getTokenAtPosition, isArrowFunction, isBlock, isCallExpression, isDeclarationName, isExpressionStatement, isFunctionLikeDeclaration, isJsxAttribute, isJsxExpression, isVariableLike, length, needsParentheses, probablyUsesSemicolons, rangeContainsRange, suppressLeadingAndTrailingTrivia, textChanges, updateFunctionLikeBody, } from "../_namespaces/edit.js";
|
|
3
|
-
import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js";
|
|
4
|
-
const fixId = "returnValueCorrect";
|
|
5
|
-
const fixIdAddReturnStatement = "fixAddReturnStatement";
|
|
6
|
-
const fixIdRemoveBlockBodyBrace = "fixRemoveBlockBodyBrace";
|
|
7
|
-
// Na tag, também o `fixWrapTheBlockWithParen`, que punha entre parênteses o corpo de uma arrow que o parser lia como um
|
|
8
|
-
// statement com label (`() => { a: 1 }`); o label saiu (CK-02), e com ele o caso que o fix tratava.
|
|
9
|
-
const errorCodes = [
|
|
10
|
-
Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code,
|
|
11
|
-
Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
12
|
-
Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code
|
|
13
|
-
];
|
|
14
|
-
// Na tag, também o problema dos parênteses que faltavam em volta de um object literal lido como label (CK-02).
|
|
15
|
-
var ProblemKind;
|
|
16
|
-
(function (ProblemKind) {
|
|
17
|
-
ProblemKind[ProblemKind["MissingReturnStatement"] = 0] = "MissingReturnStatement";
|
|
18
|
-
})(ProblemKind || (ProblemKind = {}));
|
|
19
|
-
registerCodeFix({
|
|
20
|
-
errorCodes,
|
|
21
|
-
fixIds: [fixIdAddReturnStatement, fixIdRemoveBlockBodyBrace],
|
|
22
|
-
getCodeActions: context => {
|
|
23
|
-
const { program, sourceFile, span: { start }, errorCode } = context;
|
|
24
|
-
const info = getInfo(program.getTypeChecker(), sourceFile, start, errorCode);
|
|
25
|
-
if (!info)
|
|
26
|
-
return undefined;
|
|
27
|
-
return append([getActionForfixAddReturnStatement(context, info.expression, info.statement)], isArrowFunction(info.declaration) ? getActionForfixRemoveBlockBodyBrace(context, info.declaration, info.expression, info.commentSource) : undefined);
|
|
28
|
-
},
|
|
29
|
-
getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => {
|
|
30
|
-
const info = getInfo(context.program.getTypeChecker(), diag.file, diag.start, diag.code);
|
|
31
|
-
if (!info)
|
|
32
|
-
return undefined;
|
|
33
|
-
switch (context.fixId) {
|
|
34
|
-
case fixIdAddReturnStatement:
|
|
35
|
-
addReturnStatement(changes, diag.file, info.expression, info.statement);
|
|
36
|
-
break;
|
|
37
|
-
case fixIdRemoveBlockBodyBrace:
|
|
38
|
-
if (!isArrowFunction(info.declaration))
|
|
39
|
-
return undefined;
|
|
40
|
-
removeBlockBodyBrace(changes, diag.file, info.declaration, info.expression, info.commentSource, /* withParen */ false);
|
|
41
|
-
break;
|
|
42
|
-
default:
|
|
43
|
-
Debug.fail(JSON.stringify(context.fixId));
|
|
44
|
-
}
|
|
45
|
-
}),
|
|
46
|
-
});
|
|
47
|
-
function getFixInfo(checker, declaration, expectType, isFunctionType) {
|
|
48
|
-
if (!declaration.body || !isBlock(declaration.body) || length(declaration.body.statements) !== 1)
|
|
49
|
-
return undefined;
|
|
50
|
-
const firstStatement = first(declaration.body.statements);
|
|
51
|
-
if (isExpressionStatement(firstStatement) && checkFixedAssignableTo(checker, declaration, firstStatement.expression, expectType, isFunctionType)) {
|
|
52
|
-
return {
|
|
53
|
-
declaration,
|
|
54
|
-
kind: ProblemKind.MissingReturnStatement,
|
|
55
|
-
expression: firstStatement.expression,
|
|
56
|
-
statement: firstStatement,
|
|
57
|
-
commentSource: firstStatement.expression
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// Na tag, também o statement com label, sozinho ou num bloco, que o parser lia onde se queria um object literal
|
|
61
|
-
// (`{ a: 1 }`), e que o fix trocava pelo objeto (CK-02).
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
function checkFixedAssignableTo(checker, declaration, expr, type, isFunctionType) {
|
|
65
|
-
return checker.isTypeAssignableTo(checker.getTypeAtLocation(isFunctionType ? updateFunctionLikeBody(declaration, createBlock([createReturn(expr)])) : expr), type);
|
|
66
|
-
}
|
|
67
|
-
function getInfo(checker, sourceFile, position, errorCode) {
|
|
68
|
-
const node = getTokenAtPosition(sourceFile, position);
|
|
69
|
-
if (!node.parent)
|
|
70
|
-
return undefined;
|
|
71
|
-
const declaration = findAncestor(node.parent, isFunctionLikeDeclaration);
|
|
72
|
-
switch (errorCode) {
|
|
73
|
-
case Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value.code:
|
|
74
|
-
if (!declaration || !declaration.body || !declaration.type || !rangeContainsRange(declaration.type, node))
|
|
75
|
-
return undefined;
|
|
76
|
-
return getFixInfo(checker, declaration, checker.getTypeFromTypeNode(declaration.type), /* isFunctionType */ false);
|
|
77
|
-
case Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1.code:
|
|
78
|
-
if (!declaration || !isCallExpression(declaration.parent) || !declaration.body)
|
|
79
|
-
return undefined;
|
|
80
|
-
const pos = declaration.parent.arguments.indexOf(declaration);
|
|
81
|
-
const type = checker.getContextualTypeForArgumentAtIndex(declaration.parent, pos);
|
|
82
|
-
if (!type)
|
|
83
|
-
return undefined;
|
|
84
|
-
return getFixInfo(checker, declaration, type, /* isFunctionType */ true);
|
|
85
|
-
case Diagnostics.Type_0_is_not_assignable_to_type_1.code:
|
|
86
|
-
if (!isDeclarationName(node) || !isVariableLike(node.parent) && !isJsxAttribute(node.parent))
|
|
87
|
-
return undefined;
|
|
88
|
-
const initializer = getVariableLikeInitializer(node.parent);
|
|
89
|
-
if (!initializer || !isFunctionLikeDeclaration(initializer) || !initializer.body)
|
|
90
|
-
return undefined;
|
|
91
|
-
return getFixInfo(checker, initializer, checker.getTypeAtLocation(node.parent), /* isFunctionType */ true);
|
|
92
|
-
}
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
// Na tag, também a propriedade de classe, o membro de enum (CK-02) e as tags do JSDoc (CK-03).
|
|
96
|
-
function getVariableLikeInitializer(declaration) {
|
|
97
|
-
switch (declaration.kind) {
|
|
98
|
-
case SyntaxKind.VariableDeclaration:
|
|
99
|
-
case SyntaxKind.Parameter:
|
|
100
|
-
case SyntaxKind.BindingElement:
|
|
101
|
-
case SyntaxKind.PropertyAssignment:
|
|
102
|
-
return declaration.initializer;
|
|
103
|
-
case SyntaxKind.JsxAttribute:
|
|
104
|
-
return declaration.initializer && (isJsxExpression(declaration.initializer) ? declaration.initializer.expression : undefined);
|
|
105
|
-
case SyntaxKind.ShorthandPropertyAssignment:
|
|
106
|
-
case SyntaxKind.PropertySignature:
|
|
107
|
-
return undefined;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function addReturnStatement(changes, sourceFile, expression, statement) {
|
|
111
|
-
suppressLeadingAndTrailingTrivia(expression);
|
|
112
|
-
const probablyNeedSemi = probablyUsesSemicolons(sourceFile);
|
|
113
|
-
changes.replaceNode(sourceFile, statement, createReturn(expression), {
|
|
114
|
-
leadingTriviaOption: textChanges.LeadingTriviaOption.Exclude,
|
|
115
|
-
trailingTriviaOption: textChanges.TrailingTriviaOption.Exclude,
|
|
116
|
-
suffix: probablyNeedSemi ? ";" : undefined
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
function removeBlockBodyBrace(changes, sourceFile, declaration, expression, commentSource, withParen) {
|
|
120
|
-
const newBody = (withParen || needsParentheses(expression)) ? createParen(expression) : expression;
|
|
121
|
-
suppressLeadingAndTrailingTrivia(commentSource);
|
|
122
|
-
copyComments(commentSource, newBody);
|
|
123
|
-
changes.replaceNode(sourceFile, declaration.body, newBody);
|
|
124
|
-
}
|
|
125
|
-
function getActionForfixAddReturnStatement(context, expression, statement) {
|
|
126
|
-
const changes = textChanges.ChangeTracker.with(context, t => addReturnStatement(t, context.sourceFile, expression, statement));
|
|
127
|
-
return createCodeFixAction(fixId, changes, Diagnostics.Add_a_return_statement, fixIdAddReturnStatement, Diagnostics.Add_all_missing_return_statement);
|
|
128
|
-
}
|
|
129
|
-
function getActionForfixRemoveBlockBodyBrace(context, declaration, expression, commentSource) {
|
|
130
|
-
const changes = textChanges.ChangeTracker.with(context, t => removeBlockBodyBrace(t, context.sourceFile, declaration, expression, commentSource, /* withParen */ false));
|
|
131
|
-
return createCodeFixAction(fixId, changes, Diagnostics.Remove_block_body_braces, fixIdRemoveBlockBodyBrace, Diagnostics.Remove_all_incorrect_body_block_braces);
|
|
132
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// Modificado de microsoft/TypeScript v3.9.10, src/services/codefixes/splitTypeOnlyImport.ts: o namespace virou módulo ES, com os imports explícitos.
|
|
2
|
-
import { Debug, Diagnostics, createImportDeclaration, findAncestor, getTokenAtPosition, isImportDeclaration, textChanges, updateImportClause, updateImportDeclaration, } from "../_namespaces/edit.js";
|
|
3
|
-
import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js";
|
|
4
|
-
const errorCodes = [Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both.code];
|
|
5
|
-
const fixId = "splitTypeOnlyImport";
|
|
6
|
-
registerCodeFix({
|
|
7
|
-
errorCodes,
|
|
8
|
-
fixIds: [fixId],
|
|
9
|
-
getCodeActions: context => {
|
|
10
|
-
const changes = textChanges.ChangeTracker.with(context, t => {
|
|
11
|
-
return splitTypeOnlyImport(t, getImportDeclaration(context.sourceFile, context.span), context);
|
|
12
|
-
});
|
|
13
|
-
if (changes.length) {
|
|
14
|
-
return [createCodeFixAction(fixId, changes, Diagnostics.Split_into_two_separate_import_declarations, fixId, Diagnostics.Split_all_invalid_type_only_imports)];
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, error) => {
|
|
18
|
-
splitTypeOnlyImport(changes, getImportDeclaration(context.sourceFile, error), context);
|
|
19
|
-
}),
|
|
20
|
-
});
|
|
21
|
-
function getImportDeclaration(sourceFile, span) {
|
|
22
|
-
return findAncestor(getTokenAtPosition(sourceFile, span.start), isImportDeclaration);
|
|
23
|
-
}
|
|
24
|
-
function splitTypeOnlyImport(changes, importDeclaration, context) {
|
|
25
|
-
if (!importDeclaration) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const importClause = Debug.checkDefined(importDeclaration.importClause);
|
|
29
|
-
changes.replaceNode(context.sourceFile, importDeclaration, updateImportDeclaration(importDeclaration, importDeclaration.modifiers, updateImportClause(importClause, importClause.name, /*namedBindings*/ undefined, importClause.isTypeOnly), importDeclaration.moduleSpecifier));
|
|
30
|
-
changes.insertNodeAfter(context.sourceFile, importDeclaration, createImportDeclaration(
|
|
31
|
-
/*modifiers*/ undefined, updateImportClause(importClause, /*name*/ undefined, importClause.namedBindings, importClause.isTypeOnly), importDeclaration.moduleSpecifier));
|
|
32
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Modificado de microsoft/TypeScript v3.9.10, src/services/codefixes/useBigintLiteral.ts: o namespace virou módulo ES, com os imports explícitos.
|
|
2
|
-
import { Diagnostics, createBigIntLiteral, getTokenAtPosition, isNumericLiteral, textChanges, tryCast, } from "../_namespaces/edit.js";
|
|
3
|
-
import { codeFixAll, createCodeFixAction, registerCodeFix, } from "../_namespaces/ts.codefix.js";
|
|
4
|
-
const fixId = "useBigintLiteral";
|
|
5
|
-
const errorCodes = [
|
|
6
|
-
Diagnostics.Numeric_literals_with_absolute_values_equal_to_2_53_or_greater_are_too_large_to_be_represented_accurately_as_integers.code,
|
|
7
|
-
];
|
|
8
|
-
registerCodeFix({
|
|
9
|
-
errorCodes,
|
|
10
|
-
getCodeActions: context => {
|
|
11
|
-
const changes = textChanges.ChangeTracker.with(context, t => makeChange(t, context.sourceFile, context.span));
|
|
12
|
-
if (changes.length > 0) {
|
|
13
|
-
return [createCodeFixAction(fixId, changes, Diagnostics.Convert_to_a_bigint_numeric_literal, fixId, Diagnostics.Convert_all_to_bigint_numeric_literals)];
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
fixIds: [fixId],
|
|
17
|
-
getAllCodeActions: context => {
|
|
18
|
-
return codeFixAll(context, errorCodes, (changes, diag) => makeChange(changes, diag.file, diag));
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
function makeChange(changeTracker, sourceFile, span) {
|
|
22
|
-
const numericLiteral = tryCast(getTokenAtPosition(sourceFile, span.start), isNumericLiteral);
|
|
23
|
-
if (!numericLiteral) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
// We use .getText to overcome parser inaccuracies: https://github.com/microsoft/TypeScript/issues/33298
|
|
27
|
-
const newText = numericLiteral.getText(sourceFile) + "n";
|
|
28
|
-
changeTracker.replaceNode(sourceFile, numericLiteral, createBigIntLiteral(newText));
|
|
29
|
-
}
|