@effect/language-service 0.58.2 → 0.58.3
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 +7 -9
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +7 -9
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +11 -18
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +7 -9
- 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
|
|
|
@@ -4168,18 +4172,12 @@ var annotate = createCodegen({
|
|
|
4168
4172
|
for (const variableDeclaration of variableDeclarations) {
|
|
4169
4173
|
if (!variableDeclaration.initializer) continue;
|
|
4170
4174
|
const initializerType = typeChecker.getTypeAtLocation(variableDeclaration.initializer);
|
|
4175
|
+
const enclosingNode = ts.findAncestor(variableDeclaration, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
|
|
4171
4176
|
const initializerTypeNode = fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
4172
4177
|
initializerType,
|
|
4173
|
-
|
|
4178
|
+
enclosingNode,
|
|
4174
4179
|
ts.NodeBuilderFlags.NoTruncation
|
|
4175
4180
|
)).pipe(
|
|
4176
|
-
orElse(
|
|
4177
|
-
() => fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
4178
|
-
initializerType,
|
|
4179
|
-
void 0,
|
|
4180
|
-
ts.NodeBuilderFlags.NoTruncation
|
|
4181
|
-
))
|
|
4182
|
-
),
|
|
4183
4181
|
getOrUndefined
|
|
4184
4182
|
);
|
|
4185
4183
|
if (!initializerTypeNode) continue;
|
|
@@ -16481,9 +16479,10 @@ var toggleReturnTypeAnnotation = createRefactor({
|
|
|
16481
16479
|
}
|
|
16482
16480
|
const returnType = typeCheckerUtils.getInferredReturnType(node);
|
|
16483
16481
|
if (!returnType) return yield* fail(new RefactorNotApplicableError());
|
|
16482
|
+
const enclosingNode = ts.findAncestor(node, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
|
|
16484
16483
|
const returnTypeNode = typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
16485
16484
|
returnType,
|
|
16486
|
-
|
|
16485
|
+
enclosingNode,
|
|
16487
16486
|
ts.NodeBuilderFlags.NoTruncation
|
|
16488
16487
|
);
|
|
16489
16488
|
if (!returnTypeNode) return yield* fail(new RefactorNotApplicableError());
|
|
@@ -16528,18 +16527,12 @@ var toggleTypeAnnotation = createRefactor({
|
|
|
16528
16527
|
}
|
|
16529
16528
|
const initializer = node.initializer;
|
|
16530
16529
|
const initializerType = typeChecker.getTypeAtLocation(initializer);
|
|
16530
|
+
const enclosingNode = ts.findAncestor(node, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
|
|
16531
16531
|
const initializerTypeNode = fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
16532
16532
|
initializerType,
|
|
16533
|
-
|
|
16533
|
+
enclosingNode,
|
|
16534
16534
|
ts.NodeBuilderFlags.NoTruncation
|
|
16535
16535
|
)).pipe(
|
|
16536
|
-
orElse(
|
|
16537
|
-
() => fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
16538
|
-
initializerType,
|
|
16539
|
-
void 0,
|
|
16540
|
-
ts.NodeBuilderFlags.NoTruncation
|
|
16541
|
-
))
|
|
16542
|
-
),
|
|
16543
16536
|
getOrUndefined
|
|
16544
16537
|
);
|
|
16545
16538
|
if (initializerTypeNode) {
|