@effect/language-service 0.16.2 → 0.16.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/language-service",
3
- "version": "0.16.2",
3
+ "version": "0.16.4",
4
4
  "description": "A Language-Service Plugin to Refactor and Diagnostic effect-ts projects",
5
5
  "main": "index.cjs",
6
6
  "repository": {
package/transform.js CHANGED
@@ -720,6 +720,7 @@ var isNone2 = isNone;
720
720
  var isSome2 = isSome;
721
721
 
722
722
  // node_modules/.pnpm/effect@3.12.5/node_modules/effect/dist/esm/Array.js
723
+ var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
723
724
  var isArray = Array.isArray;
724
725
  var isEmptyArray = (self) => self.length === 0;
725
726
  var isEmptyReadonlyArray = isEmptyArray;
@@ -743,6 +744,16 @@ var flatMap = /* @__PURE__ */ dual(2, (self, f) => {
743
744
  return out;
744
745
  });
745
746
  var flatten = /* @__PURE__ */ flatMap(identity);
747
+ var filter = /* @__PURE__ */ dual(2, (self, predicate) => {
748
+ const as = fromIterable(self);
749
+ const out = [];
750
+ for (let i = 0; i < as.length; i++) {
751
+ if (predicate(as[i], i)) {
752
+ out.push(as[i]);
753
+ }
754
+ }
755
+ return out;
756
+ });
746
757
 
747
758
  // src/core/Nano.ts
748
759
  var NanoInternalSuccessProto = {
@@ -1200,9 +1211,9 @@ var expectedAndRealType = fn("TypeCheckerApi.expectedAndRealType")(function* (so
1200
1211
  realType
1201
1212
  ]);
1202
1213
  });
1203
- ts.forEachChild(node, appendNodeToVisit);
1204
- continue;
1205
1214
  }
1215
+ ts.forEachChild(node, appendNodeToVisit);
1216
+ continue;
1206
1217
  } else if (ts.isIdentifier(node) || ts.isStringLiteral(node) || ts.isNumericLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) {
1207
1218
  const parent = node.parent;
1208
1219
  if (ts.isObjectLiteralElement(parent)) {
@@ -1214,12 +1225,12 @@ var expectedAndRealType = fn("TypeCheckerApi.expectedAndRealType")(function* (so
1214
1225
  const expectedType = typeChecker.getTypeOfSymbolAtLocation(symbol3, node);
1215
1226
  const realType = typeChecker.getTypeAtLocation(node);
1216
1227
  result.push([node, expectedType, node, realType]);
1217
- ts.forEachChild(node, appendNodeToVisit);
1218
- continue;
1219
1228
  }
1220
1229
  }
1221
1230
  }
1222
1231
  }
1232
+ ts.forEachChild(node, appendNodeToVisit);
1233
+ continue;
1223
1234
  } else if (ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.EqualsToken) {
1224
1235
  const expectedType = typeChecker.getTypeAtLocation(node.left);
1225
1236
  const realType = typeChecker.getTypeAtLocation(node.right);
@@ -1233,19 +1244,28 @@ var expectedAndRealType = fn("TypeCheckerApi.expectedAndRealType")(function* (so
1233
1244
  const realType = typeChecker.getTypeAtLocation(node.expression);
1234
1245
  if (isSome2(expectedType)) {
1235
1246
  result.push([node, expectedType.value, node, realType]);
1236
- ts.forEachChild(node, appendNodeToVisit);
1237
- continue;
1238
1247
  }
1239
1248
  }
1240
- } else if (ts.isArrowFunction(node) && ts.isExpression(node.body)) {
1249
+ ts.forEachChild(node, appendNodeToVisit);
1250
+ continue;
1251
+ } else if (ts.isArrowFunction(node) && (node.typeParameters || []).length === 0 && ts.isExpression(node.body)) {
1241
1252
  const body = node.body;
1242
1253
  const expectedType = typeChecker.getContextualType(body);
1243
1254
  const realType = typeChecker.getTypeAtLocation(body);
1244
1255
  if (expectedType) {
1245
1256
  result.push([body, expectedType, body, realType]);
1246
- appendNodeToVisit(body);
1247
- continue;
1248
1257
  }
1258
+ ts.forEachChild(node, appendNodeToVisit);
1259
+ continue;
1260
+ } else if (ts.isArrowFunction(node) && (node.typeParameters || []).length > 0 && ts.isExpression(node.body)) {
1261
+ const body = node.body;
1262
+ const expectedType = yield* option(getInferredReturnType(node));
1263
+ const realType = typeChecker.getTypeAtLocation(body);
1264
+ if (isSome2(expectedType)) {
1265
+ result.push([body, expectedType.value, body, realType]);
1266
+ }
1267
+ ts.forEachChild(node, appendNodeToVisit);
1268
+ continue;
1249
1269
  } else if (ts.isSatisfiesExpression(node)) {
1250
1270
  const expectedType = typeChecker.getTypeAtLocation(node.type);
1251
1271
  const realType = typeChecker.getTypeAtLocation(node.expression);
@@ -1899,8 +1919,14 @@ function transform_default(program, pluginConfig, { addDiagnostic, ts: tsInstanc
1899
1919
  provideService(PluginOptions, parsePluginOptions(pluginConfig)),
1900
1920
  run,
1901
1921
  map((_2) => _2.diagnostics),
1902
- getOrElse(() => [])
1903
- ).map(addDiagnostic);
1922
+ map(
1923
+ filter(
1924
+ (_2) => _2.category === tsInstance.DiagnosticCategory.Error || _2.category === tsInstance.DiagnosticCategory.Warning
1925
+ )
1926
+ ),
1927
+ getOrElse(() => []),
1928
+ map2(addDiagnostic)
1929
+ );
1904
1930
  return sourceFile;
1905
1931
  };
1906
1932
  };