@effect/language-service 0.58.1 → 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 CHANGED
@@ -30911,6 +30911,9 @@ function makeTypeScriptUtils(ts) {
30911
30911
  }
30912
30912
  return node;
30913
30913
  }
30914
+ function isDeclarationKind(kind) {
30915
+ 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;
30916
+ }
30914
30917
  return {
30915
30918
  findNodeAtPositionIncludingTrivia,
30916
30919
  parsePackageContentNameAndVersionFromScope,
@@ -30933,7 +30936,8 @@ function makeTypeScriptUtils(ts) {
30933
30936
  parseAccessedExpressionForCompletion,
30934
30937
  getSourceFileOfNode,
30935
30938
  isOuterExpression,
30936
- skipOuterExpressions
30939
+ skipOuterExpressions,
30940
+ isDeclarationKind
30937
30941
  };
30938
30942
  }
30939
30943
 
@@ -33459,18 +33463,12 @@ var annotate3 = createCodegen({
33459
33463
  for (const variableDeclaration of variableDeclarations) {
33460
33464
  if (!variableDeclaration.initializer) continue;
33461
33465
  const initializerType = typeChecker.getTypeAtLocation(variableDeclaration.initializer);
33466
+ const enclosingNode = ts.findAncestor(variableDeclaration, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
33462
33467
  const initializerTypeNode = fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
33463
33468
  initializerType,
33464
- node,
33469
+ enclosingNode,
33465
33470
  ts.NodeBuilderFlags.NoTruncation
33466
33471
  )).pipe(
33467
- orElse(
33468
- () => fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
33469
- initializerType,
33470
- void 0,
33471
- ts.NodeBuilderFlags.NoTruncation
33472
- ))
33473
- ),
33474
33472
  getOrUndefined
33475
33473
  );
33476
33474
  if (!initializerTypeNode) continue;
@@ -33698,9 +33696,11 @@ var anyUnknownInErrorContext = createDiagnostic({
33698
33696
  }
33699
33697
  if (ts.isParameter(node) || ts.isPropertyDeclaration(node) || ts.isVariableDeclaration(node)) {
33700
33698
  if (node.type) {
33699
+ const typeNode = node.type;
33701
33700
  const type3 = typeChecker.getTypeAtLocation(node.type);
33702
33701
  const expectedEffect = yield* pipe(
33703
33702
  typeParser.strictEffectType(type3, node.type),
33703
+ orElse14(() => typeParser.layerType(type3, typeNode)),
33704
33704
  orElse14(() => void_8)
33705
33705
  );
33706
33706
  if (expectedEffect) continue;
@@ -33722,8 +33722,9 @@ var anyUnknownInErrorContext = createDiagnostic({
33722
33722
  if (!type2) continue;
33723
33723
  yield* pipe(
33724
33724
  typeParser.strictEffectType(type2, node),
33725
- map34((effect3) => {
33726
- const { E, R } = effect3;
33725
+ orElse14(() => pipe(typeParser.layerType(type2, node), map34(({ E, RIn }) => ({ E, R: RIn })))),
33726
+ map34((effectOrLayer) => {
33727
+ const { E, R } = effectOrLayer;
33727
33728
  const hasAnyUnknownR = isAnyOrUnknown(R);
33728
33729
  const hasAnyUnknownE = isAnyOrUnknown(E);
33729
33730
  if (hasAnyUnknownR || hasAnyUnknownE) {
@@ -33746,7 +33747,7 @@ var anyUnknownInErrorContext = createDiagnostic({
33746
33747
  matchingNodes.splice(i, 1);
33747
33748
  }
33748
33749
  }
33749
- const suggestions = [`This Effect has ${channels.join(" and ")} which is not recommended.`];
33750
+ const suggestions = [`This has ${channels.join(" and ")} which is not recommended.`];
33750
33751
  if (hasAnyUnknownR) {
33751
33752
  suggestions.push(`Only service identifiers should appear in the requirements channel.`);
33752
33753
  }