@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.
Files changed (123) hide show
  1. package/NOTICE +3 -1
  2. package/dist/_namespaces/edit.d.ts +1 -1
  3. package/dist/_namespaces/edit.js +10759 -11
  4. package/dist/_namespaces/ts.codefix.d.ts +0 -1
  5. package/dist/_namespaces/ts.js +10196 -19
  6. package/dist/classifier.d.ts +3 -1
  7. package/dist/codeFixProvider.d.ts +2 -1
  8. package/dist/codefixes/helpers.d.ts +3 -1
  9. package/dist/codefixes/importFixes.d.ts +3 -1
  10. package/dist/completions.d.ts +5 -2
  11. package/dist/documentHighlights.d.ts +3 -1
  12. package/dist/documentRegistry.d.ts +2 -1
  13. package/dist/findAllReferences.d.ts +3 -1
  14. package/dist/formatting/formatting.d.ts +3 -2
  15. package/dist/formatting/formattingContext.d.ts +2 -1
  16. package/dist/formatting/formattingScanner.d.ts +2 -2
  17. package/dist/formatting/rule.d.ts +1 -1
  18. package/dist/formatting/rulesMap.d.ts +1 -1
  19. package/dist/formatting/smartIndenter.d.ts +2 -1
  20. package/dist/getEditsForFileRename.d.ts +4 -1
  21. package/dist/goToDefinition.d.ts +3 -1
  22. package/dist/importTracker.d.ts +2 -1
  23. package/dist/navigationBar.d.ts +3 -1
  24. package/dist/organizeImports.d.ts +4 -2
  25. package/dist/outliningElementsCollector.d.ts +3 -1
  26. package/dist/refactorProvider.d.ts +1 -1
  27. package/dist/refactors/extractSymbol.d.ts +2 -1
  28. package/dist/rename.d.ts +3 -1
  29. package/dist/services.d.ts +5 -2
  30. package/dist/signatureHelp.d.ts +3 -1
  31. package/dist/smartSelection.d.ts +2 -1
  32. package/dist/stringCompletions.d.ts +3 -1
  33. package/dist/suggestionDiagnostics.d.ts +4 -3
  34. package/dist/symbolDisplay.d.ts +3 -1
  35. package/dist/textChanges.d.ts +4 -2
  36. package/dist/types.d.ts +3 -3
  37. package/dist/utilities.d.ts +7 -2
  38. package/package.json +7 -5
  39. package/dist/_namespaces/ts.Completions.StringCompletions.js +0 -2
  40. package/dist/_namespaces/ts.Completions.js +0 -3
  41. package/dist/_namespaces/ts.FindAllReferences.js +0 -3
  42. package/dist/_namespaces/ts.GoToDefinition.js +0 -2
  43. package/dist/_namespaces/ts.NavigationBar.js +0 -2
  44. package/dist/_namespaces/ts.OrganizeImports.js +0 -2
  45. package/dist/_namespaces/ts.OutliningElementsCollector.js +0 -2
  46. package/dist/_namespaces/ts.Rename.js +0 -2
  47. package/dist/_namespaces/ts.SignatureHelp.js +0 -2
  48. package/dist/_namespaces/ts.SmartSelectionRange.js +0 -2
  49. package/dist/_namespaces/ts.SymbolDisplay.js +0 -2
  50. package/dist/_namespaces/ts.codefix.js +0 -27
  51. package/dist/_namespaces/ts.formatting.js +0 -8
  52. package/dist/_namespaces/ts.refactor.addOrRemoveBracesToArrowFunction.js +0 -2
  53. package/dist/_namespaces/ts.refactor.convertParamsToDestructuredObject.js +0 -2
  54. package/dist/_namespaces/ts.refactor.convertStringOrTemplateLiteral.js +0 -2
  55. package/dist/_namespaces/ts.refactor.extractSymbol.js +0 -2
  56. package/dist/_namespaces/ts.refactor.js +0 -10
  57. package/dist/_namespaces/ts.textChanges.js +0 -2
  58. package/dist/classifier.js +0 -715
  59. package/dist/codeFixProvider.js +0 -84
  60. package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.d.ts +0 -1
  61. package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.js +0 -21
  62. package/dist/codefixes/addEmptyExportDeclaration.js +0 -17
  63. package/dist/codefixes/addMissingAsync.js +0 -75
  64. package/dist/codefixes/addMissingAwait.js +0 -236
  65. package/dist/codefixes/addMissingConst.js +0 -91
  66. package/dist/codefixes/addNameToNamelessParameter.js +0 -29
  67. package/dist/codefixes/convertConstToLet.js +0 -30
  68. package/dist/codefixes/convertToAsyncFunction.js +0 -495
  69. package/dist/codefixes/convertToMappedObjectType.js +0 -48
  70. package/dist/codefixes/correctQualifiedNameToIndexedAccessType.js +0 -33
  71. package/dist/codefixes/fixAddModuleReferTypeMissingTypeof.js +0 -27
  72. package/dist/codefixes/fixAwaitInSyncFunction.js +0 -69
  73. package/dist/codefixes/fixExpectedComma.js +0 -35
  74. package/dist/codefixes/fixInvalidJsxCharacters.js +0 -41
  75. package/dist/codefixes/fixMissingCallParentheses.js +0 -42
  76. package/dist/codefixes/fixSpelling.js +0 -94
  77. package/dist/codefixes/fixUnreachableCode.js +0 -65
  78. package/dist/codefixes/fixUnusedIdentifier.js +0 -224
  79. package/dist/codefixes/helpers.js +0 -53
  80. package/dist/codefixes/importFixes.js +0 -441
  81. package/dist/codefixes/inferFromUsage.js +0 -742
  82. package/dist/codefixes/removeUnnecessaryAwait.js +0 -41
  83. package/dist/codefixes/returnValueCorrect.js +0 -132
  84. package/dist/codefixes/splitTypeOnlyImport.js +0 -32
  85. package/dist/codefixes/useBigintLiteral.js +0 -29
  86. package/dist/completions.js +0 -1720
  87. package/dist/documentHighlights.js +0 -367
  88. package/dist/documentRegistry.js +0 -63
  89. package/dist/editingServices.js +0 -4
  90. package/dist/findAllReferences.js +0 -1366
  91. package/dist/formatting/formatting.js +0 -1021
  92. package/dist/formatting/formattingContext.js +0 -78
  93. package/dist/formatting/formattingScanner.js +0 -228
  94. package/dist/formatting/rule.js +0 -22
  95. package/dist/formatting/rules.js +0 -610
  96. package/dist/formatting/rulesMap.js +0 -127
  97. package/dist/formatting/smartIndenter.js +0 -518
  98. package/dist/getEditsForFileRename.js +0 -86
  99. package/dist/goToDefinition.js +0 -246
  100. package/dist/importTracker.js +0 -422
  101. package/dist/index.js +0 -3
  102. package/dist/navigationBar.js +0 -549
  103. package/dist/organizeImports.js +0 -290
  104. package/dist/outliningElementsCollector.js +0 -261
  105. package/dist/refactorProvider.js +0 -16
  106. package/dist/refactors/addOrRemoveBracesToArrowFunction.js +0 -86
  107. package/dist/refactors/convertExport.js +0 -126
  108. package/dist/refactors/convertImport.js +0 -116
  109. package/dist/refactors/convertParamsToDestructuredObject.js +0 -282
  110. package/dist/refactors/convertStringOrTemplateLiteral.js +0 -148
  111. package/dist/refactors/extractSymbol.js +0 -1281
  112. package/dist/refactors/extractType.js +0 -102
  113. package/dist/refactors/moveToNewFile.js +0 -477
  114. package/dist/rename.js +0 -100
  115. package/dist/services.js +0 -1480
  116. package/dist/signatureHelp.js +0 -414
  117. package/dist/smartSelection.js +0 -243
  118. package/dist/stringCompletions.js +0 -220
  119. package/dist/suggestionDiagnostics.js +0 -92
  120. package/dist/symbolDisplay.js +0 -400
  121. package/dist/textChanges.js +0 -1163
  122. package/dist/types.js +0 -263
  123. 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
- }