@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.
@@ -1797,6 +1797,9 @@ function makeTypeScriptUtils(ts) {
1797
1797
  }
1798
1798
  return node;
1799
1799
  }
1800
+ function isDeclarationKind(kind) {
1801
+ 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;
1802
+ }
1800
1803
  return {
1801
1804
  findNodeAtPositionIncludingTrivia,
1802
1805
  parsePackageContentNameAndVersionFromScope,
@@ -1819,7 +1822,8 @@ function makeTypeScriptUtils(ts) {
1819
1822
  parseAccessedExpressionForCompletion,
1820
1823
  getSourceFileOfNode,
1821
1824
  isOuterExpression,
1822
- skipOuterExpressions
1825
+ skipOuterExpressions,
1826
+ isDeclarationKind
1823
1827
  };
1824
1828
  }
1825
1829
 
@@ -2576,7 +2580,16 @@ function make2(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
2576
2580
  const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
2577
2581
  if (!moduleSymbol) continue;
2578
2582
  const memberSymbol = typeChecker.tryGetMemberInModuleExports(memberName, moduleSymbol);
2579
- if (memberSymbol && memberSymbol === symbol3) result.push({ memberSymbol, moduleSymbol, sourceFile });
2583
+ if (memberSymbol) {
2584
+ if (memberSymbol === symbol3) {
2585
+ result.push({ memberSymbol, moduleSymbol, sourceFile });
2586
+ } else if (memberSymbol.flags & ts.SymbolFlags.Alias) {
2587
+ const aliased = typeChecker.getAliasedSymbol(memberSymbol);
2588
+ if (aliased === symbol3) {
2589
+ result.push({ memberSymbol, moduleSymbol, sourceFile });
2590
+ }
2591
+ }
2592
+ }
2580
2593
  }
2581
2594
  if (result.length > 0) {
2582
2595
  return result;
@@ -5589,18 +5602,12 @@ var annotate = createCodegen({
5589
5602
  for (const variableDeclaration of variableDeclarations) {
5590
5603
  if (!variableDeclaration.initializer) continue;
5591
5604
  const initializerType = typeChecker.getTypeAtLocation(variableDeclaration.initializer);
5605
+ const enclosingNode = ts.findAncestor(variableDeclaration, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
5592
5606
  const initializerTypeNode = fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
5593
5607
  initializerType,
5594
- node,
5595
- ts.NodeBuilderFlags.NoTruncation
5608
+ enclosingNode,
5609
+ ts.NodeBuilderFlags.NoTruncation | ts.NodeBuilderFlags.IgnoreErrors
5596
5610
  )).pipe(
5597
- orElse(
5598
- () => fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
5599
- initializerType,
5600
- void 0,
5601
- ts.NodeBuilderFlags.NoTruncation
5602
- ))
5603
- ),
5604
5611
  getOrUndefined
5605
5612
  );
5606
5613
  if (!initializerTypeNode) continue;