@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/language-service",
3
- "version": "0.58.1",
3
+ "version": "0.58.3",
4
4
  "description": "A Language-Service Plugin to Refactor and Diagnostic effect-ts projects",
5
5
  "main": "index.cjs",
6
6
  "bin": {
package/transform.js CHANGED
@@ -1798,6 +1798,9 @@ function makeTypeScriptUtils(ts) {
1798
1798
  }
1799
1799
  return node;
1800
1800
  }
1801
+ function isDeclarationKind(kind) {
1802
+ 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;
1803
+ }
1801
1804
  return {
1802
1805
  findNodeAtPositionIncludingTrivia,
1803
1806
  parsePackageContentNameAndVersionFromScope,
@@ -1820,7 +1823,8 @@ function makeTypeScriptUtils(ts) {
1820
1823
  parseAccessedExpressionForCompletion,
1821
1824
  getSourceFileOfNode,
1822
1825
  isOuterExpression,
1823
- skipOuterExpressions
1826
+ skipOuterExpressions,
1827
+ isDeclarationKind
1824
1828
  };
1825
1829
  }
1826
1830
 
@@ -3681,9 +3685,11 @@ var anyUnknownInErrorContext = createDiagnostic({
3681
3685
  }
3682
3686
  if (ts.isParameter(node) || ts.isPropertyDeclaration(node) || ts.isVariableDeclaration(node)) {
3683
3687
  if (node.type) {
3688
+ const typeNode = node.type;
3684
3689
  const type2 = typeChecker.getTypeAtLocation(node.type);
3685
3690
  const expectedEffect = yield* pipe(
3686
3691
  typeParser.strictEffectType(type2, node.type),
3692
+ orElse2(() => typeParser.layerType(type2, typeNode)),
3687
3693
  orElse2(() => void_)
3688
3694
  );
3689
3695
  if (expectedEffect) continue;
@@ -3705,8 +3711,9 @@ var anyUnknownInErrorContext = createDiagnostic({
3705
3711
  if (!type) continue;
3706
3712
  yield* pipe(
3707
3713
  typeParser.strictEffectType(type, node),
3708
- map4((effect) => {
3709
- const { E, R } = effect;
3714
+ orElse2(() => pipe(typeParser.layerType(type, node), map4(({ E, RIn }) => ({ E, R: RIn })))),
3715
+ map4((effectOrLayer) => {
3716
+ const { E, R } = effectOrLayer;
3710
3717
  const hasAnyUnknownR = isAnyOrUnknown(R);
3711
3718
  const hasAnyUnknownE = isAnyOrUnknown(E);
3712
3719
  if (hasAnyUnknownR || hasAnyUnknownE) {
@@ -3729,7 +3736,7 @@ var anyUnknownInErrorContext = createDiagnostic({
3729
3736
  matchingNodes.splice(i, 1);
3730
3737
  }
3731
3738
  }
3732
- const suggestions = [`This Effect has ${channels.join(" and ")} which is not recommended.`];
3739
+ const suggestions = [`This has ${channels.join(" and ")} which is not recommended.`];
3733
3740
  if (hasAnyUnknownR) {
3734
3741
  suggestions.push(`Only service identifiers should appear in the requirements channel.`);
3735
3742
  }
@@ -5582,18 +5589,12 @@ var annotate = createCodegen({
5582
5589
  for (const variableDeclaration of variableDeclarations) {
5583
5590
  if (!variableDeclaration.initializer) continue;
5584
5591
  const initializerType = typeChecker.getTypeAtLocation(variableDeclaration.initializer);
5592
+ const enclosingNode = ts.findAncestor(variableDeclaration, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
5585
5593
  const initializerTypeNode = fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
5586
5594
  initializerType,
5587
- node,
5595
+ enclosingNode,
5588
5596
  ts.NodeBuilderFlags.NoTruncation
5589
5597
  )).pipe(
5590
- orElse(
5591
- () => fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
5592
- initializerType,
5593
- void 0,
5594
- ts.NodeBuilderFlags.NoTruncation
5595
- ))
5596
- ),
5597
5598
  getOrUndefined
5598
5599
  );
5599
5600
  if (!initializerTypeNode) continue;