@tslite/services 1.16.1 → 1.18.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.d.ts +1 -0
- package/dist/_namespaces/ts.js +34 -33
- package/dist/packageVersion.d.ts +2 -0
- 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.d.ts
CHANGED
package/dist/_namespaces/ts.js
CHANGED
|
@@ -5,6 +5,9 @@ var __export = (target, all) => {
|
|
|
5
5
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
// src/packageVersion.ts
|
|
9
|
+
var packageVersion = "1.18.0";
|
|
10
|
+
|
|
8
11
|
// src/_namespaces/ts.ts
|
|
9
12
|
export * from "@tslite/checker";
|
|
10
13
|
|
|
@@ -281,7 +284,6 @@ import {
|
|
|
281
284
|
isAnyImportSyntax,
|
|
282
285
|
isArray,
|
|
283
286
|
isArrayTypeNode,
|
|
284
|
-
isAsExpression,
|
|
285
287
|
isAwaitExpression,
|
|
286
288
|
isBinaryExpression,
|
|
287
289
|
isBindingElement,
|
|
@@ -872,9 +874,6 @@ function getAdjustedLocation(node, forRename) {
|
|
|
872
874
|
if (node.kind === SyntaxKind.InKeyword && isBinaryExpression(parent2) && parent2.operatorToken === node) {
|
|
873
875
|
return skipOuterExpressions(parent2.right);
|
|
874
876
|
}
|
|
875
|
-
if (node.kind === SyntaxKind.AsKeyword && isAsExpression(parent2) && isTypeReferenceNode(parent2.type)) {
|
|
876
|
-
return parent2.type.typeName;
|
|
877
|
-
}
|
|
878
877
|
if (node.kind === SyntaxKind.InKeyword && isForInStatement(parent2) || node.kind === SyntaxKind.OfKeyword && isForOfStatement(parent2)) {
|
|
879
878
|
return skipOuterExpressions(parent2.expression);
|
|
880
879
|
}
|
|
@@ -1295,7 +1294,6 @@ function createTextChange(span, newText) {
|
|
|
1295
1294
|
return { span, newText };
|
|
1296
1295
|
}
|
|
1297
1296
|
var typeKeywords = [
|
|
1298
|
-
SyntaxKind.AnyKeyword,
|
|
1299
1297
|
SyntaxKind.AssertsKeyword,
|
|
1300
1298
|
SyntaxKind.BigIntKeyword,
|
|
1301
1299
|
SyntaxKind.BooleanKeyword,
|
|
@@ -1307,11 +1305,11 @@ var typeKeywords = [
|
|
|
1307
1305
|
SyntaxKind.ObjectKeyword,
|
|
1308
1306
|
SyntaxKind.ReadonlyKeyword,
|
|
1309
1307
|
SyntaxKind.StringKeyword,
|
|
1310
|
-
SyntaxKind.SymbolKeyword,
|
|
1311
1308
|
SyntaxKind.TrueKeyword,
|
|
1312
1309
|
SyntaxKind.VoidKeyword,
|
|
1313
1310
|
SyntaxKind.UndefinedKeyword,
|
|
1314
|
-
// Na tag, também o `unique`, que saiu do scanner com o `unique symbol` (CK-02, CK-56)
|
|
1311
|
+
// 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
|
|
1312
|
+
// 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
1313
|
SyntaxKind.UnknownKeyword
|
|
1316
1314
|
];
|
|
1317
1315
|
function isTypeKeyword(kind) {
|
|
@@ -2093,7 +2091,6 @@ function createClassifier() {
|
|
|
2093
2091
|
angleBracketStack--;
|
|
2094
2092
|
}
|
|
2095
2093
|
break;
|
|
2096
|
-
case SyntaxKind2.AnyKeyword:
|
|
2097
2094
|
case SyntaxKind2.StringKeyword:
|
|
2098
2095
|
case SyntaxKind2.NumberKeyword:
|
|
2099
2096
|
case SyntaxKind2.BooleanKeyword:
|
|
@@ -2948,7 +2945,6 @@ import {
|
|
|
2948
2945
|
getRootDeclaration as getRootDeclaration2,
|
|
2949
2946
|
hasInitializer,
|
|
2950
2947
|
hasType,
|
|
2951
|
-
isAssertionExpression,
|
|
2952
2948
|
isBinaryExpression as isBinaryExpression2,
|
|
2953
2949
|
isBindingElement as isBindingElement2,
|
|
2954
2950
|
isCallExpression as isCallExpression2,
|
|
@@ -3740,7 +3736,7 @@ function getCompletionData(program, log, sourceFile, position, preferences, deta
|
|
|
3740
3736
|
function filterGlobalCompletion(symbols2) {
|
|
3741
3737
|
const isTypeOnly2 = isTypeOnlyCompletion();
|
|
3742
3738
|
if (isTypeOnly2) {
|
|
3743
|
-
keywordFilters =
|
|
3739
|
+
keywordFilters = 4 /* TypeKeywords */;
|
|
3744
3740
|
}
|
|
3745
3741
|
filterMutate(symbols2, (symbol) => {
|
|
3746
3742
|
if (!isSourceFile2(location)) {
|
|
@@ -3755,9 +3751,6 @@ function getCompletionData(program, log, sourceFile, position, preferences, deta
|
|
|
3755
3751
|
return !!(getCombinedLocalAndExportSymbolFlags(symbol) & SymbolFlags3.Value);
|
|
3756
3752
|
});
|
|
3757
3753
|
}
|
|
3758
|
-
function isTypeAssertion() {
|
|
3759
|
-
return isAssertionExpression(contextToken.parent);
|
|
3760
|
-
}
|
|
3761
3754
|
function isTypeOnlyCompletion() {
|
|
3762
3755
|
return !isContextTokenValueLocation(contextToken) && (isPossiblyTypeArgumentPosition(contextToken, sourceFile, typeChecker) || isPartOfTypeNode2(location) || isContextTokenTypeLocation(contextToken));
|
|
3763
3756
|
}
|
|
@@ -3772,8 +3765,6 @@ function getCompletionData(program, log, sourceFile, position, preferences, deta
|
|
|
3772
3765
|
return parentKind === SyntaxKind4.PropertySignature || parentKind === SyntaxKind4.Parameter || parentKind === SyntaxKind4.VariableDeclaration || isFunctionLikeKind(parentKind);
|
|
3773
3766
|
case SyntaxKind4.EqualsToken:
|
|
3774
3767
|
return parentKind === SyntaxKind4.TypeAliasDeclaration;
|
|
3775
|
-
case SyntaxKind4.AsKeyword:
|
|
3776
|
-
return parentKind === SyntaxKind4.AsExpression;
|
|
3777
3768
|
case SyntaxKind4.LessThanToken:
|
|
3778
3769
|
return parentKind === SyntaxKind4.TypeReference;
|
|
3779
3770
|
case SyntaxKind4.ExtendsKeyword:
|
|
@@ -4262,9 +4253,7 @@ function getTypescriptKeywordCompletions(keywordFilter) {
|
|
|
4262
4253
|
return isFunctionLikeBodyKeyword(kind);
|
|
4263
4254
|
case 2 /* InterfaceElementKeywords */:
|
|
4264
4255
|
return isInterfaceOrTypeLiteralCompletionKeyword(kind);
|
|
4265
|
-
case 4 /*
|
|
4266
|
-
return isTypeKeyword(kind) || kind === SyntaxKind4.ConstKeyword;
|
|
4267
|
-
case 5 /* TypeKeywords */:
|
|
4256
|
+
case 4 /* TypeKeywords */:
|
|
4268
4257
|
return isTypeKeyword(kind);
|
|
4269
4258
|
default:
|
|
4270
4259
|
return Debug4.assertNever(keywordFilter);
|
|
@@ -5281,7 +5270,6 @@ import {
|
|
|
5281
5270
|
getTextOfNode,
|
|
5282
5271
|
hasInitializer as hasInitializer2,
|
|
5283
5272
|
hasType as hasType2,
|
|
5284
|
-
isAssertionExpression as isAssertionExpression2,
|
|
5285
5273
|
isBinaryExpression as isBinaryExpression3,
|
|
5286
5274
|
isBindingElement as isBindingElement4,
|
|
5287
5275
|
isBreakOrContinueStatement as isBreakOrContinueStatement2,
|
|
@@ -5447,6 +5435,9 @@ function findReferencedSymbols(program, cancellationToken, sourceFiles, sourceFi
|
|
|
5447
5435
|
}
|
|
5448
5436
|
function getImplementationsAtPosition(program, cancellationToken, sourceFiles, sourceFile, position) {
|
|
5449
5437
|
const node = getTouchingPropertyName(sourceFile, position);
|
|
5438
|
+
if (node === sourceFile) {
|
|
5439
|
+
return void 0;
|
|
5440
|
+
}
|
|
5450
5441
|
let referenceEntries;
|
|
5451
5442
|
const entries = getImplementationReferenceEntries(program, cancellationToken, sourceFiles, node, position);
|
|
5452
5443
|
if (node.parent.kind === SyntaxKind7.PropertyAccessExpression || node.parent.kind === SyntaxKind7.BindingElement || node.parent.kind === SyntaxKind7.ElementAccessExpression) {
|
|
@@ -6284,8 +6275,6 @@ var Core;
|
|
|
6284
6275
|
} else {
|
|
6285
6276
|
addIfImplementation(body);
|
|
6286
6277
|
}
|
|
6287
|
-
} else if (isAssertionExpression2(typeHavingNode)) {
|
|
6288
|
-
addIfImplementation(typeHavingNode.expression);
|
|
6289
6278
|
}
|
|
6290
6279
|
}
|
|
6291
6280
|
function addIfImplementation(e) {
|
|
@@ -8120,9 +8109,11 @@ import {
|
|
|
8120
8109
|
createDiagnosticForNode,
|
|
8121
8110
|
createMap as createMap7,
|
|
8122
8111
|
forEachReturnStatement as forEachReturnStatement3,
|
|
8112
|
+
hasInitializer as hasInitializer3,
|
|
8123
8113
|
isAsyncFunction,
|
|
8124
8114
|
isBlock as isBlock4,
|
|
8125
8115
|
isCallExpression as isCallExpression7,
|
|
8116
|
+
isFunctionLike as isFunctionLike6,
|
|
8126
8117
|
isFunctionLikeDeclaration as isFunctionLikeDeclaration3,
|
|
8127
8118
|
isIdentifier as isIdentifier8,
|
|
8128
8119
|
isPropertyAccessExpression as isPropertyAccessExpression5,
|
|
@@ -8130,6 +8121,9 @@ import {
|
|
|
8130
8121
|
isVariableDeclaration as isVariableDeclaration5,
|
|
8131
8122
|
some as some3
|
|
8132
8123
|
} from "@tslite/parser";
|
|
8124
|
+
import {
|
|
8125
|
+
skipAlias as skipAlias3
|
|
8126
|
+
} from "@tslite/checker";
|
|
8133
8127
|
var visitedNestedConvertibleFunctions = createMap7();
|
|
8134
8128
|
function computeSuggestionDiagnostics(sourceFile, program, cancellationToken) {
|
|
8135
8129
|
program.getSemanticDiagnostics(sourceFile, cancellationToken);
|
|
@@ -8156,7 +8150,7 @@ function addConvertToAsyncFunctionDiagnostics(node, checker, diags) {
|
|
|
8156
8150
|
}
|
|
8157
8151
|
}
|
|
8158
8152
|
function isConvertibleFunction(node, checker) {
|
|
8159
|
-
return !isAsyncFunction(node) && node.body && isBlock4(node.body) && hasReturnStatementWithPromiseHandler(node.body) && returnsPromise(node, checker);
|
|
8153
|
+
return !isAsyncFunction(node) && node.body && isBlock4(node.body) && hasReturnStatementWithPromiseHandler(node.body, checker) && returnsPromise(node, checker);
|
|
8160
8154
|
}
|
|
8161
8155
|
function returnsPromise(node, checker) {
|
|
8162
8156
|
const functionType = checker.getTypeAtLocation(node);
|
|
@@ -8164,19 +8158,19 @@ function returnsPromise(node, checker) {
|
|
|
8164
8158
|
const returnType = callSignatures.length ? checker.getReturnTypeOfSignature(callSignatures[0]) : void 0;
|
|
8165
8159
|
return !!returnType && !!checker.getPromisedTypeOfPromise(returnType);
|
|
8166
8160
|
}
|
|
8167
|
-
function hasReturnStatementWithPromiseHandler(body) {
|
|
8168
|
-
return !!forEachReturnStatement3(body, isReturnStatementWithFixablePromiseHandler);
|
|
8161
|
+
function hasReturnStatementWithPromiseHandler(body, checker) {
|
|
8162
|
+
return !!forEachReturnStatement3(body, (statement) => isReturnStatementWithFixablePromiseHandler(statement, checker));
|
|
8169
8163
|
}
|
|
8170
|
-
function isReturnStatementWithFixablePromiseHandler(node) {
|
|
8171
|
-
return isReturnStatement2(node) && !!node.expression && isFixablePromiseHandler(node.expression);
|
|
8164
|
+
function isReturnStatementWithFixablePromiseHandler(node, checker) {
|
|
8165
|
+
return isReturnStatement2(node) && !!node.expression && isFixablePromiseHandler(node.expression, checker);
|
|
8172
8166
|
}
|
|
8173
|
-
function isFixablePromiseHandler(node) {
|
|
8174
|
-
if (!isPromiseHandler(node) || !node.arguments.every(isFixablePromiseArgument)) {
|
|
8167
|
+
function isFixablePromiseHandler(node, checker) {
|
|
8168
|
+
if (!isPromiseHandler(node) || !node.arguments.every((arg) => isFixablePromiseArgument(arg, checker))) {
|
|
8175
8169
|
return false;
|
|
8176
8170
|
}
|
|
8177
8171
|
let currentNode = node.expression;
|
|
8178
8172
|
while (isPromiseHandler(currentNode) || isPropertyAccessExpression5(currentNode)) {
|
|
8179
|
-
if (isCallExpression7(currentNode) && !currentNode.arguments.every(isFixablePromiseArgument)) {
|
|
8173
|
+
if (isCallExpression7(currentNode) && !currentNode.arguments.every((arg) => isFixablePromiseArgument(arg, checker))) {
|
|
8180
8174
|
return false;
|
|
8181
8175
|
}
|
|
8182
8176
|
currentNode = currentNode.expression;
|
|
@@ -8193,14 +8187,20 @@ function hasSupportedNumberOfArguments(node) {
|
|
|
8193
8187
|
return arg.kind === SyntaxKind14.NullKeyword || isIdentifier8(arg) && arg.text === "undefined";
|
|
8194
8188
|
});
|
|
8195
8189
|
}
|
|
8196
|
-
function isFixablePromiseArgument(arg) {
|
|
8190
|
+
function isFixablePromiseArgument(arg, checker) {
|
|
8197
8191
|
switch (arg.kind) {
|
|
8198
8192
|
case SyntaxKind14.ArrowFunction:
|
|
8199
8193
|
visitedNestedConvertibleFunctions.set(getKeyFromNode(arg), true);
|
|
8200
8194
|
// falls through
|
|
8201
8195
|
case SyntaxKind14.NullKeyword:
|
|
8202
|
-
case SyntaxKind14.Identifier:
|
|
8203
8196
|
return true;
|
|
8197
|
+
case SyntaxKind14.Identifier: {
|
|
8198
|
+
const symbol = checker.getSymbolAtLocation(arg);
|
|
8199
|
+
if (!symbol) {
|
|
8200
|
+
return false;
|
|
8201
|
+
}
|
|
8202
|
+
return checker.isUndefinedSymbol(symbol) || some3(skipAlias3(symbol, checker).declarations, (d) => isFunctionLike6(d) || hasInitializer3(d) && !!d.initializer && isFunctionLike6(d.initializer));
|
|
8203
|
+
}
|
|
8204
8204
|
default:
|
|
8205
8205
|
return false;
|
|
8206
8206
|
}
|
|
@@ -8236,7 +8236,7 @@ import {
|
|
|
8236
8236
|
isCallExpression as isCallExpression8,
|
|
8237
8237
|
isCatchClause as isCatchClause3,
|
|
8238
8238
|
isFunctionBlock as isFunctionBlock2,
|
|
8239
|
-
isFunctionLike as
|
|
8239
|
+
isFunctionLike as isFunctionLike7,
|
|
8240
8240
|
isFunctionLikeKind as isFunctionLikeKind2,
|
|
8241
8241
|
isJsxOpeningLikeElement as isJsxOpeningLikeElement3,
|
|
8242
8242
|
isLet as isLet2,
|
|
@@ -8346,7 +8346,7 @@ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, so
|
|
|
8346
8346
|
callExpressionLike = location;
|
|
8347
8347
|
} else if (isCallExpressionTarget(location)) {
|
|
8348
8348
|
callExpressionLike = location.parent;
|
|
8349
|
-
} else if (location.parent && isJsxOpeningLikeElement3(location.parent) &&
|
|
8349
|
+
} else if (location.parent && isJsxOpeningLikeElement3(location.parent) && isFunctionLike7(symbol.valueDeclaration)) {
|
|
8350
8350
|
callExpressionLike = location.parent;
|
|
8351
8351
|
}
|
|
8352
8352
|
if (callExpressionLike) {
|
|
@@ -10157,6 +10157,7 @@ export {
|
|
|
10157
10157
|
needsParentheses,
|
|
10158
10158
|
nodeSeenTracker,
|
|
10159
10159
|
operatorPart,
|
|
10160
|
+
packageVersion,
|
|
10160
10161
|
positionBelongsToNode,
|
|
10161
10162
|
positionIsASICandidate,
|
|
10162
10163
|
probablyUsesSemicolons,
|
|
@@ -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.18.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/parser": "1.
|
|
29
|
-
"@tslite/
|
|
30
|
-
"@tslite/printer": "1.
|
|
27
|
+
"@tslite/checker": "1.18.0",
|
|
28
|
+
"@tslite/parser": "1.18.0",
|
|
29
|
+
"@tslite/binder": "1.18.0",
|
|
30
|
+
"@tslite/printer": "1.18.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@tslite/oracle": "0.1.
|
|
33
|
+
"@tslite/oracle": "0.1.4"
|
|
34
34
|
},
|
|
35
35
|
"repository": {
|
|
36
36
|
"type": "git",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|