@effect/language-service 0.16.4 → 0.16.6

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/index.js CHANGED
@@ -1980,7 +1980,7 @@ var expectedAndRealType = fn("TypeCheckerApi.expectedAndRealType")(function* (so
1980
1980
  if (expectedType) {
1981
1981
  result.push([body, expectedType, body, realType]);
1982
1982
  }
1983
- ts.forEachChild(node, appendNodeToVisit);
1983
+ ts.forEachChild(body, appendNodeToVisit);
1984
1984
  continue;
1985
1985
  } else if (ts.isArrowFunction(node) && (node.typeParameters || []).length > 0 && ts.isExpression(node.body)) {
1986
1986
  const body = node.body;
@@ -1989,7 +1989,7 @@ var expectedAndRealType = fn("TypeCheckerApi.expectedAndRealType")(function* (so
1989
1989
  if (isSome2(expectedType)) {
1990
1990
  result.push([body, expectedType.value, body, realType]);
1991
1991
  }
1992
- ts.forEachChild(node, appendNodeToVisit);
1992
+ ts.forEachChild(body, appendNodeToVisit);
1993
1993
  continue;
1994
1994
  } else if (ts.isSatisfiesExpression(node)) {
1995
1995
  const expectedType = typeChecker.getTypeAtLocation(node.type);
@@ -2887,21 +2887,31 @@ var effectGenToFn = createRefactor({
2887
2887
  const parseEffectGenNode = fn("asyncAwaitToGen.apply")(function* (node) {
2888
2888
  const effectGen2 = yield* effectGen(node);
2889
2889
  let pipeArgs2 = ts.factory.createNodeArray([]);
2890
- let nodeToReplace2 = node.parent;
2891
- if (ts.isPropertyAccessExpression(node.parent) && node.parent.name.text === "pipe" && ts.isCallExpression(node.parent.parent)) {
2892
- pipeArgs2 = node.parent.parent.arguments;
2893
- nodeToReplace2 = node.parent.parent.parent;
2894
- }
2895
- while (nodeToReplace2) {
2896
- if (ts.isArrowFunction(nodeToReplace2) || ts.isFunctionDeclaration(nodeToReplace2) || ts.isMethodDeclaration(nodeToReplace2)) {
2897
- return { ...effectGen2, pipeArgs: pipeArgs2, nodeToReplace: nodeToReplace2 };
2890
+ let nodeToReplace2 = node;
2891
+ while (nodeToReplace2.parent) {
2892
+ const parent = nodeToReplace2.parent;
2893
+ if (ts.isConciseBody(nodeToReplace2) && ts.isArrowFunction(parent) && parent.body === nodeToReplace2) {
2894
+ return { ...effectGen2, pipeArgs: pipeArgs2, nodeToReplace: parent };
2895
+ }
2896
+ if ((ts.isFunctionDeclaration(parent) || ts.isMethodDeclaration(parent)) && parent.body === nodeToReplace2) {
2897
+ return { ...effectGen2, pipeArgs: pipeArgs2, nodeToReplace: parent };
2898
+ }
2899
+ if (ts.isBlock(parent) && parent.statements.length === 1 && parent.statements[0] === nodeToReplace2) {
2900
+ nodeToReplace2 = parent;
2901
+ continue;
2902
+ }
2903
+ if (ts.isReturnStatement(parent) && parent.expression === nodeToReplace2) {
2904
+ nodeToReplace2 = parent;
2905
+ continue;
2898
2906
  }
2899
- if (ts.isConciseBody(nodeToReplace2) || ts.isReturnStatement(nodeToReplace2)) {
2900
- nodeToReplace2 = nodeToReplace2.parent;
2907
+ if (ts.isPropertyAccessExpression(parent) && parent.expression === nodeToReplace2 && parent.name.text === "pipe" && ts.isCallExpression(parent.parent)) {
2908
+ pipeArgs2 = ts.factory.createNodeArray(pipeArgs2.concat(parent.parent.arguments));
2909
+ nodeToReplace2 = parent.parent;
2901
2910
  continue;
2902
2911
  }
2903
- if (ts.isBlock(nodeToReplace2) && nodeToReplace2.statements.length === 1) {
2904
- nodeToReplace2 = nodeToReplace2.parent;
2912
+ if (ts.isCallExpression(parent) && ts.isIdentifier(parent.expression) && parent.expression.text === "pipe" && parent.arguments.length > 0 && parent.arguments[0] === nodeToReplace2) {
2913
+ pipeArgs2 = ts.factory.createNodeArray(pipeArgs2.concat(parent.arguments.slice(1)));
2914
+ nodeToReplace2 = parent;
2905
2915
  continue;
2906
2916
  }
2907
2917
  break;