@tslite/services 1.16.1 → 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/dist/_namespaces/edit.js +707 -735
- package/dist/_namespaces/ts.codefix.d.ts +0 -1
- package/dist/_namespaces/ts.js +30 -33
- package/dist/suggestionDiagnostics.d.ts +3 -3
- package/dist/types.d.ts +0 -2
- package/package.json +6 -6
- package/dist/codefixes/addConvertToUnknownForNonOverlappingTypes.d.ts +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export * from "../codeFixProvider.js";
|
|
2
|
-
export * from "../codefixes/addConvertToUnknownForNonOverlappingTypes.js";
|
|
3
2
|
export * from "../codefixes/addEmptyExportDeclaration.js";
|
|
4
3
|
export * from "../codefixes/addMissingAsync.js";
|
|
5
4
|
export * from "../codefixes/addMissingAwait.js";
|
package/dist/_namespaces/ts.js
CHANGED
|
@@ -281,7 +281,6 @@ import {
|
|
|
281
281
|
isAnyImportSyntax,
|
|
282
282
|
isArray,
|
|
283
283
|
isArrayTypeNode,
|
|
284
|
-
isAsExpression,
|
|
285
284
|
isAwaitExpression,
|
|
286
285
|
isBinaryExpression,
|
|
287
286
|
isBindingElement,
|
|
@@ -872,9 +871,6 @@ function getAdjustedLocation(node, forRename) {
|
|
|
872
871
|
if (node.kind === SyntaxKind.InKeyword && isBinaryExpression(parent2) && parent2.operatorToken === node) {
|
|
873
872
|
return skipOuterExpressions(parent2.right);
|
|
874
873
|
}
|
|
875
|
-
if (node.kind === SyntaxKind.AsKeyword && isAsExpression(parent2) && isTypeReferenceNode(parent2.type)) {
|
|
876
|
-
return parent2.type.typeName;
|
|
877
|
-
}
|
|
878
874
|
if (node.kind === SyntaxKind.InKeyword && isForInStatement(parent2) || node.kind === SyntaxKind.OfKeyword && isForOfStatement(parent2)) {
|
|
879
875
|
return skipOuterExpressions(parent2.expression);
|
|
880
876
|
}
|
|
@@ -1295,7 +1291,6 @@ function createTextChange(span, newText) {
|
|
|
1295
1291
|
return { span, newText };
|
|
1296
1292
|
}
|
|
1297
1293
|
var typeKeywords = [
|
|
1298
|
-
SyntaxKind.AnyKeyword,
|
|
1299
1294
|
SyntaxKind.AssertsKeyword,
|
|
1300
1295
|
SyntaxKind.BigIntKeyword,
|
|
1301
1296
|
SyntaxKind.BooleanKeyword,
|
|
@@ -1307,11 +1302,11 @@ var typeKeywords = [
|
|
|
1307
1302
|
SyntaxKind.ObjectKeyword,
|
|
1308
1303
|
SyntaxKind.ReadonlyKeyword,
|
|
1309
1304
|
SyntaxKind.StringKeyword,
|
|
1310
|
-
SyntaxKind.SymbolKeyword,
|
|
1311
1305
|
SyntaxKind.TrueKeyword,
|
|
1312
1306
|
SyntaxKind.VoidKeyword,
|
|
1313
1307
|
SyntaxKind.UndefinedKeyword,
|
|
1314
|
-
// Na tag, também o `unique`, que saiu do scanner com o `unique symbol` (CK-02, CK-56)
|
|
1308
|
+
// Na tag, também o `unique`, que saiu do scanner com o `unique symbol` (CK-02, CK-56); e o `symbol`, que não é tipo da
|
|
1309
|
+
// Linguagem (CK-02) e é um nome comum (CK-56): o scanner ainda o dá como token, para o printer, mas ele não se oferece.
|
|
1315
1310
|
SyntaxKind.UnknownKeyword
|
|
1316
1311
|
];
|
|
1317
1312
|
function isTypeKeyword(kind) {
|
|
@@ -2093,7 +2088,6 @@ function createClassifier() {
|
|
|
2093
2088
|
angleBracketStack--;
|
|
2094
2089
|
}
|
|
2095
2090
|
break;
|
|
2096
|
-
case SyntaxKind2.AnyKeyword:
|
|
2097
2091
|
case SyntaxKind2.StringKeyword:
|
|
2098
2092
|
case SyntaxKind2.NumberKeyword:
|
|
2099
2093
|
case SyntaxKind2.BooleanKeyword:
|
|
@@ -2948,7 +2942,6 @@ import {
|
|
|
2948
2942
|
getRootDeclaration as getRootDeclaration2,
|
|
2949
2943
|
hasInitializer,
|
|
2950
2944
|
hasType,
|
|
2951
|
-
isAssertionExpression,
|
|
2952
2945
|
isBinaryExpression as isBinaryExpression2,
|
|
2953
2946
|
isBindingElement as isBindingElement2,
|
|
2954
2947
|
isCallExpression as isCallExpression2,
|
|
@@ -3740,7 +3733,7 @@ function getCompletionData(program, log, sourceFile, position, preferences, deta
|
|
|
3740
3733
|
function filterGlobalCompletion(symbols2) {
|
|
3741
3734
|
const isTypeOnly2 = isTypeOnlyCompletion();
|
|
3742
3735
|
if (isTypeOnly2) {
|
|
3743
|
-
keywordFilters =
|
|
3736
|
+
keywordFilters = 4 /* TypeKeywords */;
|
|
3744
3737
|
}
|
|
3745
3738
|
filterMutate(symbols2, (symbol) => {
|
|
3746
3739
|
if (!isSourceFile2(location)) {
|
|
@@ -3755,9 +3748,6 @@ function getCompletionData(program, log, sourceFile, position, preferences, deta
|
|
|
3755
3748
|
return !!(getCombinedLocalAndExportSymbolFlags(symbol) & SymbolFlags3.Value);
|
|
3756
3749
|
});
|
|
3757
3750
|
}
|
|
3758
|
-
function isTypeAssertion() {
|
|
3759
|
-
return isAssertionExpression(contextToken.parent);
|
|
3760
|
-
}
|
|
3761
3751
|
function isTypeOnlyCompletion() {
|
|
3762
3752
|
return !isContextTokenValueLocation(contextToken) && (isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker) || isPartOfTypeNode2(location) || isContextTokenTypeLocation(contextToken));
|
|
3763
3753
|
}
|
|
@@ -3772,8 +3762,6 @@ function getCompletionData(program, log, sourceFile, position, preferences, deta
|
|
|
3772
3762
|
return parentKind === SyntaxKind4.PropertySignature || parentKind === SyntaxKind4.Parameter || parentKind === SyntaxKind4.VariableDeclaration || isFunctionLikeKind(parentKind);
|
|
3773
3763
|
case SyntaxKind4.EqualsToken:
|
|
3774
3764
|
return parentKind === SyntaxKind4.TypeAliasDeclaration;
|
|
3775
|
-
case SyntaxKind4.AsKeyword:
|
|
3776
|
-
return parentKind === SyntaxKind4.AsExpression;
|
|
3777
3765
|
case SyntaxKind4.LessThanToken:
|
|
3778
3766
|
return parentKind === SyntaxKind4.TypeReference;
|
|
3779
3767
|
case SyntaxKind4.ExtendsKeyword:
|
|
@@ -4262,9 +4250,7 @@ function getTypescriptKeywordCompletions(keywordFilter) {
|
|
|
4262
4250
|
return isFunctionLikeBodyKeyword(kind);
|
|
4263
4251
|
case 2 /* InterfaceElementKeywords */:
|
|
4264
4252
|
return isInterfaceOrTypeLiteralCompletionKeyword(kind);
|
|
4265
|
-
case 4 /*
|
|
4266
|
-
return isTypeKeyword(kind) || kind === SyntaxKind4.ConstKeyword;
|
|
4267
|
-
case 5 /* TypeKeywords */:
|
|
4253
|
+
case 4 /* TypeKeywords */:
|
|
4268
4254
|
return isTypeKeyword(kind);
|
|
4269
4255
|
default:
|
|
4270
4256
|
return Debug4.assertNever(keywordFilter);
|
|
@@ -5281,7 +5267,6 @@ import {
|
|
|
5281
5267
|
getTextOfNode,
|
|
5282
5268
|
hasInitializer as hasInitializer2,
|
|
5283
5269
|
hasType as hasType2,
|
|
5284
|
-
isAssertionExpression as isAssertionExpression2,
|
|
5285
5270
|
isBinaryExpression as isBinaryExpression3,
|
|
5286
5271
|
isBindingElement as isBindingElement4,
|
|
5287
5272
|
isBreakOrContinueStatement as isBreakOrContinueStatement2,
|
|
@@ -5447,6 +5432,9 @@ function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFi
|
|
|
5447
5432
|
}
|
|
5448
5433
|
function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
|
|
5449
5434
|
const node = getTouchingPropertyName(sourceFile, position);
|
|
5435
|
+
if (node === sourceFile) {
|
|
5436
|
+
return void 0;
|
|
5437
|
+
}
|
|
5450
5438
|
let referenceEntries;
|
|
5451
5439
|
const entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position);
|
|
5452
5440
|
if (node.parent.kind === SyntaxKind7.PropertyAccessExpression || node.parent.kind === SyntaxKind7.BindingElement || node.parent.kind === SyntaxKind7.ElementAccessExpression) {
|
|
@@ -6284,8 +6272,6 @@ var Core;
|
|
|
6284
6272
|
} else {
|
|
6285
6273
|
addIfImplementation(body);
|
|
6286
6274
|
}
|
|
6287
|
-
} else if (isAssertionExpression2(typeHavingNode)) {
|
|
6288
|
-
addIfImplementation(typeHavingNode.expression);
|
|
6289
6275
|
}
|
|
6290
6276
|
}
|
|
6291
6277
|
function addIfImplementation(e) {
|
|
@@ -8120,9 +8106,11 @@ import {
|
|
|
8120
8106
|
createDiagnosticForNode,
|
|
8121
8107
|
createMap as createMap7,
|
|
8122
8108
|
forEachReturnStatement as forEachReturnStatement3,
|
|
8109
|
+
hasInitializer as hasInitializer3,
|
|
8123
8110
|
isAsyncFunction,
|
|
8124
8111
|
isBlock as isBlock4,
|
|
8125
8112
|
isCallExpression as isCallExpression7,
|
|
8113
|
+
isFunctionLike as isFunctionLike6,
|
|
8126
8114
|
isFunctionLikeDeclaration as isFunctionLikeDeclaration3,
|
|
8127
8115
|
isIdentifier as isIdentifier8,
|
|
8128
8116
|
isPropertyAccessExpression as isPropertyAccessExpression5,
|
|
@@ -8130,6 +8118,9 @@ import {
|
|
|
8130
8118
|
isVariableDeclaration as isVariableDeclaration5,
|
|
8131
8119
|
some as some3
|
|
8132
8120
|
} from "@tslite/parser";
|
|
8121
|
+
import {
|
|
8122
|
+
skipAlias as skipAlias3
|
|
8123
|
+
} from "@tslite/checker";
|
|
8133
8124
|
var visitedNestedConvertibleFunctions = createMap7();
|
|
8134
8125
|
function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
8135
8126
|
program.getSemanticDiagnostics(sourceFile, cancellationToken);
|
|
@@ -8156,7 +8147,7 @@ function addConvertToAsyncFunctionDiagnostics(node, checker, diags) {
|
|
|
8156
8147
|
}
|
|
8157
8148
|
}
|
|
8158
8149
|
function isConvertibleFunction(node, checker) {
|
|
8159
|
-
return !isAsyncFunction(node) && node.body && isBlock4(node.body) && hasReturnStatementWithPromiseHandler(node.body) && returnsPromise(node, checker);
|
|
8150
|
+
return !isAsyncFunction(node) && node.body && isBlock4(node.body) && hasReturnStatementWithPromiseHandler(node.body, checker) && returnsPromise(node, checker);
|
|
8160
8151
|
}
|
|
8161
8152
|
function returnsPromise(node, checker) {
|
|
8162
8153
|
const functionType = checker.getTypeAtLocation(node);
|
|
@@ -8164,19 +8155,19 @@ function returnsPromise(node, checker) {
|
|
|
8164
8155
|
const returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : void 0;
|
|
8165
8156
|
return !!returnType && !!checker.getPromisedTypeOfPromise(returnType);
|
|
8166
8157
|
}
|
|
8167
|
-
function hasReturnStatementWithPromiseHandler(body) {
|
|
8168
|
-
return !!forEachReturnStatement3(body, isReturnStatementWithFixablePromiseHandler);
|
|
8158
|
+
function hasReturnStatementWithPromiseHandler(body, checker) {
|
|
8159
|
+
return !!forEachReturnStatement3(body, (statement) => isReturnStatementWithFixablePromiseHandler(statement, checker));
|
|
8169
8160
|
}
|
|
8170
|
-
function isReturnStatementWithFixablePromiseHandler(node) {
|
|
8171
|
-
return isReturnStatement2(node) && !!node.expression && isFixablePromiseHandler(node.expression);
|
|
8161
|
+
function isReturnStatementWithFixablePromiseHandler(node, checker) {
|
|
8162
|
+
return isReturnStatement2(node) && !!node.expression && isFixablePromiseHandler(node.expression, checker);
|
|
8172
8163
|
}
|
|
8173
|
-
function isFixablePromiseHandler(node) {
|
|
8174
|
-
if (!isPromiseHandler(node) || !node.arguments.every(isFixablePromiseArgument)) {
|
|
8164
|
+
function isFixablePromiseHandler(node, checker) {
|
|
8165
|
+
if (!isPromiseHandler(node) || !node.arguments.every((arg) => isFixablePromiseArgument(arg, checker))) {
|
|
8175
8166
|
return false;
|
|
8176
8167
|
}
|
|
8177
8168
|
let currentNode = node.expression;
|
|
8178
8169
|
while (isPromiseHandler(currentNode) || isPropertyAccessExpression5(currentNode)) {
|
|
8179
|
-
if (isCallExpression7(currentNode) && !currentNode.arguments.every(isFixablePromiseArgument)) {
|
|
8170
|
+
if (isCallExpression7(currentNode) && !currentNode.arguments.every((arg) => isFixablePromiseArgument(arg, checker))) {
|
|
8180
8171
|
return false;
|
|
8181
8172
|
}
|
|
8182
8173
|
currentNode = currentNode.expression;
|
|
@@ -8193,14 +8184,20 @@ function hasSupportedNumberOfArguments(node) {
|
|
|
8193
8184
|
return arg.kind === SyntaxKind14.NullKeyword || isIdentifier8(arg) && arg.text === "undefined";
|
|
8194
8185
|
});
|
|
8195
8186
|
}
|
|
8196
|
-
function isFixablePromiseArgument(arg) {
|
|
8187
|
+
function isFixablePromiseArgument(arg, checker) {
|
|
8197
8188
|
switch (arg.kind) {
|
|
8198
8189
|
case SyntaxKind14.ArrowFunction:
|
|
8199
8190
|
visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true);
|
|
8200
8191
|
// falls through
|
|
8201
8192
|
case SyntaxKind14.NullKeyword:
|
|
8202
|
-
case SyntaxKind14.Identifier:
|
|
8203
8193
|
return true;
|
|
8194
|
+
case SyntaxKind14.Identifier: {
|
|
8195
|
+
const symbol = checker.getSymbolAtLocation(arg);
|
|
8196
|
+
if (!symbol) {
|
|
8197
|
+
return false;
|
|
8198
|
+
}
|
|
8199
|
+
return checker.isUndefinedSymbol(symbol) || some3(skipAlias3(symbol, checker).declarations, (d) => isFunctionLike6(d) || hasInitializer3(d) && !!d.initializer && isFunctionLike6(d.initializer));
|
|
8200
|
+
}
|
|
8204
8201
|
default:
|
|
8205
8202
|
return false;
|
|
8206
8203
|
}
|
|
@@ -8236,7 +8233,7 @@ import {
|
|
|
8236
8233
|
isCallExpression as isCallExpression8,
|
|
8237
8234
|
isCatchClause as isCatchClause3,
|
|
8238
8235
|
isFunctionBlock as isFunctionBlock2,
|
|
8239
|
-
isFunctionLike as
|
|
8236
|
+
isFunctionLike as isFunctionLike7,
|
|
8240
8237
|
isFunctionLikeKind as isFunctionLikeKind2,
|
|
8241
8238
|
isJsxOpeningLikeElement as isJsxOpeningLikeElement3,
|
|
8242
8239
|
isLet as isLet2,
|
|
@@ -8346,7 +8343,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
8346
8343
|
callExpressionLike = location;
|
|
8347
8344
|
} else if (isCallExpressionTarget(location)) {
|
|
8348
8345
|
callExpressionLike = location.parent;
|
|
8349
|
-
} else if (location.parent && isJsxOpeningLikeElement3(location.parent) &&
|
|
8346
|
+
} else if (location.parent && isJsxOpeningLikeElement3(location.parent) && isFunctionLike7(symbol.valueDeclaration)) {
|
|
8350
8347
|
callExpressionLike = location.parent;
|
|
8351
8348
|
}
|
|
8352
8349
|
if (callExpressionLike) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CallExpression, DiagnosticWithLocation, Node, ReturnStatement, SourceFile } from "@tslite/parser";
|
|
2
|
-
import type { CancellationToken, CheckResult } from "@tslite/checker";
|
|
2
|
+
import type { CancellationToken, CheckResult, TypeChecker } from "@tslite/checker";
|
|
3
3
|
export declare function computeSuggestionDiagnostics(sourceFile: SourceFile, program: CheckResult, cancellationToken: CancellationToken): DiagnosticWithLocation[];
|
|
4
|
-
export declare function isReturnStatementWithFixablePromiseHandler(node: Node): node is ReturnStatement & {
|
|
4
|
+
export declare function isReturnStatementWithFixablePromiseHandler(node: Node, checker: TypeChecker): node is ReturnStatement & {
|
|
5
5
|
expression: CallExpression;
|
|
6
6
|
};
|
|
7
|
-
export declare function isFixablePromiseHandler(node: Node): boolean;
|
|
7
|
+
export declare function isFixablePromiseHandler(node: Node, checker: TypeChecker): boolean;
|
package/dist/types.d.ts
CHANGED
|
@@ -516,7 +516,6 @@ export interface FormatCodeOptions extends EditorOptions {
|
|
|
516
516
|
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean;
|
|
517
517
|
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: boolean;
|
|
518
518
|
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
|
|
519
|
-
InsertSpaceAfterTypeAssertion?: boolean;
|
|
520
519
|
InsertSpaceBeforeFunctionParenthesis?: boolean;
|
|
521
520
|
PlaceOpenBraceOnNewLineForFunctions: boolean;
|
|
522
521
|
PlaceOpenBraceOnNewLineForControlBlocks: boolean;
|
|
@@ -535,7 +534,6 @@ export interface FormatCodeSettings extends EditorSettings {
|
|
|
535
534
|
readonly insertSpaceAfterOpeningAndBeforeClosingEmptyBraces?: boolean;
|
|
536
535
|
readonly insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean;
|
|
537
536
|
readonly insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean;
|
|
538
|
-
readonly insertSpaceAfterTypeAssertion?: boolean;
|
|
539
537
|
readonly insertSpaceBeforeFunctionParenthesis?: boolean;
|
|
540
538
|
readonly placeOpenBraceOnNewLineForFunctions?: boolean;
|
|
541
539
|
readonly placeOpenBraceOnNewLineForControlBlocks?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tslite/services",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "The tsc 3.9.10 language service, copied from the tag and cut down to the TSLite Language, over the copy of the tsc checker",
|
|
5
5
|
"author": "Anderson D. Rosa <andersondrosa@outlook.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,13 +24,13 @@
|
|
|
24
24
|
"NOTICE"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@tslite/
|
|
28
|
-
"@tslite/
|
|
29
|
-
"@tslite/
|
|
30
|
-
"@tslite/printer": "1.
|
|
27
|
+
"@tslite/checker": "1.17.0",
|
|
28
|
+
"@tslite/binder": "1.17.0",
|
|
29
|
+
"@tslite/parser": "1.17.0",
|
|
30
|
+
"@tslite/printer": "1.17.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@tslite/oracle": "0.1.
|
|
33
|
+
"@tslite/oracle": "0.1.3"
|
|
34
34
|
},
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|