@effect/language-service 0.58.2 → 0.58.4
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/cli.js +18 -11
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +18 -11
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +24 -22
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +18 -11
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -1845,6 +1845,9 @@ function makeTypeScriptUtils(ts) {
|
|
|
1845
1845
|
}
|
|
1846
1846
|
return node;
|
|
1847
1847
|
}
|
|
1848
|
+
function isDeclarationKind(kind) {
|
|
1849
|
+
return kind === ts.SyntaxKind.ArrowFunction || kind === ts.SyntaxKind.BindingElement || kind === ts.SyntaxKind.ClassDeclaration || kind === ts.SyntaxKind.ClassExpression || kind === ts.SyntaxKind.ClassStaticBlockDeclaration || kind === ts.SyntaxKind.Constructor || kind === ts.SyntaxKind.EnumDeclaration || kind === ts.SyntaxKind.EnumMember || kind === ts.SyntaxKind.ExportSpecifier || kind === ts.SyntaxKind.FunctionDeclaration || kind === ts.SyntaxKind.FunctionExpression || kind === ts.SyntaxKind.GetAccessor || kind === ts.SyntaxKind.ImportClause || kind === ts.SyntaxKind.ImportEqualsDeclaration || kind === ts.SyntaxKind.ImportSpecifier || kind === ts.SyntaxKind.InterfaceDeclaration || kind === ts.SyntaxKind.JsxAttribute || kind === ts.SyntaxKind.MethodDeclaration || kind === ts.SyntaxKind.MethodSignature || kind === ts.SyntaxKind.ModuleDeclaration || kind === ts.SyntaxKind.NamespaceExportDeclaration || kind === ts.SyntaxKind.NamespaceImport || kind === ts.SyntaxKind.NamespaceExport || kind === ts.SyntaxKind.Parameter || kind === ts.SyntaxKind.PropertyAssignment || kind === ts.SyntaxKind.PropertyDeclaration || kind === ts.SyntaxKind.PropertySignature || kind === ts.SyntaxKind.SetAccessor || kind === ts.SyntaxKind.ShorthandPropertyAssignment || kind === ts.SyntaxKind.TypeAliasDeclaration || kind === ts.SyntaxKind.TypeParameter || kind === ts.SyntaxKind.VariableDeclaration || kind === ts.SyntaxKind.JSDocTypedefTag || kind === ts.SyntaxKind.JSDocCallbackTag || kind === ts.SyntaxKind.JSDocPropertyTag || kind === ts.SyntaxKind.NamedTupleMember;
|
|
1850
|
+
}
|
|
1848
1851
|
return {
|
|
1849
1852
|
findNodeAtPositionIncludingTrivia,
|
|
1850
1853
|
parsePackageContentNameAndVersionFromScope,
|
|
@@ -1867,7 +1870,8 @@ function makeTypeScriptUtils(ts) {
|
|
|
1867
1870
|
parseAccessedExpressionForCompletion,
|
|
1868
1871
|
getSourceFileOfNode,
|
|
1869
1872
|
isOuterExpression,
|
|
1870
|
-
skipOuterExpressions
|
|
1873
|
+
skipOuterExpressions,
|
|
1874
|
+
isDeclarationKind
|
|
1871
1875
|
};
|
|
1872
1876
|
}
|
|
1873
1877
|
|
|
@@ -2770,7 +2774,16 @@ function make3(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
2770
2774
|
const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
|
|
2771
2775
|
if (!moduleSymbol) continue;
|
|
2772
2776
|
const memberSymbol = typeChecker.tryGetMemberInModuleExports(memberName, moduleSymbol);
|
|
2773
|
-
if (memberSymbol
|
|
2777
|
+
if (memberSymbol) {
|
|
2778
|
+
if (memberSymbol === symbol3) {
|
|
2779
|
+
result.push({ memberSymbol, moduleSymbol, sourceFile });
|
|
2780
|
+
} else if (memberSymbol.flags & ts.SymbolFlags.Alias) {
|
|
2781
|
+
const aliased = typeChecker.getAliasedSymbol(memberSymbol);
|
|
2782
|
+
if (aliased === symbol3) {
|
|
2783
|
+
result.push({ memberSymbol, moduleSymbol, sourceFile });
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2774
2787
|
}
|
|
2775
2788
|
if (result.length > 0) {
|
|
2776
2789
|
return result;
|
|
@@ -4168,18 +4181,12 @@ var annotate = createCodegen({
|
|
|
4168
4181
|
for (const variableDeclaration of variableDeclarations) {
|
|
4169
4182
|
if (!variableDeclaration.initializer) continue;
|
|
4170
4183
|
const initializerType = typeChecker.getTypeAtLocation(variableDeclaration.initializer);
|
|
4184
|
+
const enclosingNode = ts.findAncestor(variableDeclaration, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
|
|
4171
4185
|
const initializerTypeNode = fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
4172
4186
|
initializerType,
|
|
4173
|
-
|
|
4174
|
-
ts.NodeBuilderFlags.NoTruncation
|
|
4187
|
+
enclosingNode,
|
|
4188
|
+
ts.NodeBuilderFlags.NoTruncation | ts.NodeBuilderFlags.IgnoreErrors
|
|
4175
4189
|
)).pipe(
|
|
4176
|
-
orElse(
|
|
4177
|
-
() => fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
4178
|
-
initializerType,
|
|
4179
|
-
void 0,
|
|
4180
|
-
ts.NodeBuilderFlags.NoTruncation
|
|
4181
|
-
))
|
|
4182
|
-
),
|
|
4183
4190
|
getOrUndefined
|
|
4184
4191
|
);
|
|
4185
4192
|
if (!initializerTypeNode) continue;
|
|
@@ -16481,10 +16488,11 @@ var toggleReturnTypeAnnotation = createRefactor({
|
|
|
16481
16488
|
}
|
|
16482
16489
|
const returnType = typeCheckerUtils.getInferredReturnType(node);
|
|
16483
16490
|
if (!returnType) return yield* fail(new RefactorNotApplicableError());
|
|
16491
|
+
const enclosingNode = ts.findAncestor(node, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
|
|
16484
16492
|
const returnTypeNode = typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
16485
16493
|
returnType,
|
|
16486
|
-
|
|
16487
|
-
ts.NodeBuilderFlags.NoTruncation
|
|
16494
|
+
enclosingNode,
|
|
16495
|
+
ts.NodeBuilderFlags.NoTruncation | ts.NodeBuilderFlags.IgnoreErrors
|
|
16488
16496
|
);
|
|
16489
16497
|
if (!returnTypeNode) return yield* fail(new RefactorNotApplicableError());
|
|
16490
16498
|
return {
|
|
@@ -16528,18 +16536,12 @@ var toggleTypeAnnotation = createRefactor({
|
|
|
16528
16536
|
}
|
|
16529
16537
|
const initializer = node.initializer;
|
|
16530
16538
|
const initializerType = typeChecker.getTypeAtLocation(initializer);
|
|
16539
|
+
const enclosingNode = ts.findAncestor(node, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
|
|
16531
16540
|
const initializerTypeNode = fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
16532
16541
|
initializerType,
|
|
16533
|
-
|
|
16534
|
-
ts.NodeBuilderFlags.NoTruncation
|
|
16542
|
+
enclosingNode,
|
|
16543
|
+
ts.NodeBuilderFlags.NoTruncation | ts.NodeBuilderFlags.IgnoreErrors
|
|
16535
16544
|
)).pipe(
|
|
16536
|
-
orElse(
|
|
16537
|
-
() => fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
16538
|
-
initializerType,
|
|
16539
|
-
void 0,
|
|
16540
|
-
ts.NodeBuilderFlags.NoTruncation
|
|
16541
|
-
))
|
|
16542
|
-
),
|
|
16543
16545
|
getOrUndefined
|
|
16544
16546
|
);
|
|
16545
16547
|
if (initializerTypeNode) {
|