@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.
@@ -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
 
@@ -3685,9 +3689,11 @@ var anyUnknownInErrorContext = createDiagnostic({
3685
3689
  }
3686
3690
  if (ts.isParameter(node) || ts.isPropertyDeclaration(node) || ts.isVariableDeclaration(node)) {
3687
3691
  if (node.type) {
3692
+ const typeNode = node.type;
3688
3693
  const type2 = typeChecker.getTypeAtLocation(node.type);
3689
3694
  const expectedEffect = yield* pipe(
3690
3695
  typeParser.strictEffectType(type2, node.type),
3696
+ orElse2(() => typeParser.layerType(type2, typeNode)),
3691
3697
  orElse2(() => void_)
3692
3698
  );
3693
3699
  if (expectedEffect) continue;
@@ -3709,8 +3715,9 @@ var anyUnknownInErrorContext = createDiagnostic({
3709
3715
  if (!type) continue;
3710
3716
  yield* pipe(
3711
3717
  typeParser.strictEffectType(type, node),
3712
- map4((effect) => {
3713
- const { E, R } = effect;
3718
+ orElse2(() => pipe(typeParser.layerType(type, node), map4(({ E, RIn }) => ({ E, R: RIn })))),
3719
+ map4((effectOrLayer) => {
3720
+ const { E, R } = effectOrLayer;
3714
3721
  const hasAnyUnknownR = isAnyOrUnknown(R);
3715
3722
  const hasAnyUnknownE = isAnyOrUnknown(E);
3716
3723
  if (hasAnyUnknownR || hasAnyUnknownE) {
@@ -3733,7 +3740,7 @@ var anyUnknownInErrorContext = createDiagnostic({
3733
3740
  matchingNodes.splice(i, 1);
3734
3741
  }
3735
3742
  }
3736
- const suggestions = [`This Effect has ${channels.join(" and ")} which is not recommended.`];
3743
+ const suggestions = [`This has ${channels.join(" and ")} which is not recommended.`];
3737
3744
  if (hasAnyUnknownR) {
3738
3745
  suggestions.push(`Only service identifiers should appear in the requirements channel.`);
3739
3746
  }
@@ -5586,18 +5593,12 @@ var annotate = createCodegen({
5586
5593
  for (const variableDeclaration of variableDeclarations) {
5587
5594
  if (!variableDeclaration.initializer) continue;
5588
5595
  const initializerType = typeChecker.getTypeAtLocation(variableDeclaration.initializer);
5596
+ const enclosingNode = ts.findAncestor(variableDeclaration, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
5589
5597
  const initializerTypeNode = fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
5590
5598
  initializerType,
5591
- node,
5599
+ enclosingNode,
5592
5600
  ts.NodeBuilderFlags.NoTruncation
5593
5601
  )).pipe(
5594
- orElse(
5595
- () => fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
5596
- initializerType,
5597
- void 0,
5598
- ts.NodeBuilderFlags.NoTruncation
5599
- ))
5600
- ),
5601
5602
  getOrUndefined
5602
5603
  );
5603
5604
  if (!initializerTypeNode) continue;