@effect/language-service 0.35.2 → 0.37.0

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/transform.js CHANGED
@@ -24,7 +24,7 @@ __export(transform_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(transform_exports);
26
26
 
27
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Function.js
27
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Function.js
28
28
  var isFunction = (input) => typeof input === "function";
29
29
  var dual = function(arity, body) {
30
30
  if (typeof arity === "function") {
@@ -118,7 +118,7 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
118
118
  }
119
119
  }
120
120
 
121
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/GlobalValue.js
121
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/GlobalValue.js
122
122
  var globalStoreId = `effect/GlobalValue`;
123
123
  var globalStore;
124
124
  var globalValue = (id, compute) => {
@@ -132,7 +132,7 @@ var globalValue = (id, compute) => {
132
132
  return globalStore.get(id);
133
133
  };
134
134
 
135
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Predicate.js
135
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Predicate.js
136
136
  var isString = (input) => typeof input === "string";
137
137
  var isNumber = (input) => typeof input === "number";
138
138
  var isBoolean = (input) => typeof input === "boolean";
@@ -142,7 +142,7 @@ var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
142
142
  var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
143
143
  var isRecord = (input) => isRecordOrArray(input) && !Array.isArray(input);
144
144
 
145
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Utils.js
145
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Utils.js
146
146
  var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
147
147
  var GenKindImpl = class {
148
148
  value;
@@ -264,7 +264,7 @@ var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forc
264
264
  var genConstructor = function* () {
265
265
  }.constructor;
266
266
 
267
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Hash.js
267
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Hash.js
268
268
  var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
269
269
  var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
270
270
  var hash = (self) => {
@@ -331,10 +331,10 @@ var string = (str) => {
331
331
  }
332
332
  return optimize(h);
333
333
  };
334
- var structureKeys = (o, keys) => {
334
+ var structureKeys = (o, keys2) => {
335
335
  let h = 12289;
336
- for (let i = 0; i < keys.length; i++) {
337
- h ^= pipe(string(keys[i]), combine(hash(o[keys[i]])));
336
+ for (let i = 0; i < keys2.length; i++) {
337
+ h ^= pipe(string(keys2[i]), combine(hash(o[keys2[i]])));
338
338
  }
339
339
  return optimize(h);
340
340
  };
@@ -363,7 +363,7 @@ var cached = function() {
363
363
  return hash2;
364
364
  };
365
365
 
366
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Equal.js
366
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Equal.js
367
367
  var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
368
368
  function equals() {
369
369
  if (arguments.length === 1) {
@@ -417,7 +417,7 @@ function compareBoth(self, that) {
417
417
  var isEqual = (u) => hasProperty(u, symbol2);
418
418
  var equivalence = () => equals;
419
419
 
420
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Inspectable.js
420
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Inspectable.js
421
421
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
422
422
  var toJSON = (x) => {
423
423
  try {
@@ -469,7 +469,7 @@ var redact = (u) => {
469
469
  return u;
470
470
  };
471
471
 
472
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Pipeable.js
472
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Pipeable.js
473
473
  var pipeArguments = (self, args2) => {
474
474
  switch (args2.length) {
475
475
  case 0:
@@ -502,14 +502,14 @@ var pipeArguments = (self, args2) => {
502
502
  }
503
503
  };
504
504
 
505
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/opCodes/effect.js
505
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/opCodes/effect.js
506
506
  var OP_COMMIT = "Commit";
507
507
 
508
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/version.js
509
- var moduleVersion = "3.17.1";
508
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/version.js
509
+ var moduleVersion = "3.17.8";
510
510
  var getCurrentVersion = () => moduleVersion;
511
511
 
512
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/effectable.js
512
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/effectable.js
513
513
  var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
514
514
  var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
515
515
  var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
@@ -596,7 +596,7 @@ var StructuralCommitPrototype = {
596
596
  ...StructuralPrototype
597
597
  };
598
598
 
599
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/option.js
599
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/option.js
600
600
  var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
601
601
  var CommonProto = {
602
602
  ...EffectPrototype,
@@ -654,7 +654,7 @@ var some = (value) => {
654
654
  return a;
655
655
  };
656
656
 
657
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/either.js
657
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/either.js
658
658
  var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
659
659
  var CommonProto2 = {
660
660
  ...EffectPrototype,
@@ -716,7 +716,7 @@ var right = (right3) => {
716
716
  return a;
717
717
  };
718
718
 
719
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Either.js
719
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Either.js
720
720
  var right2 = right;
721
721
  var left2 = left;
722
722
  var isLeft2 = isLeft;
@@ -724,14 +724,14 @@ var isRight2 = isRight;
724
724
  var map = /* @__PURE__ */ dual(2, (self, f) => isRight2(self) ? right2(f(self.right)) : left2(self.left));
725
725
  var getOrElse = /* @__PURE__ */ dual(2, (self, onLeft) => isLeft2(self) ? onLeft(self.left) : self.right);
726
726
 
727
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/internal/array.js
727
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/array.js
728
728
  var isNonEmptyArray = (self) => self.length > 0;
729
729
 
730
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Order.js
730
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Order.js
731
731
  var make = (compare) => (self, that) => self === that ? 0 : compare(self, that);
732
732
  var string2 = /* @__PURE__ */ make((self, that) => self < that ? -1 : 1);
733
733
 
734
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Option.js
734
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Option.js
735
735
  var none2 = () => none;
736
736
  var some2 = some;
737
737
  var isNone2 = isNone;
@@ -739,7 +739,19 @@ var isSome2 = isSome;
739
739
  var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : self);
740
740
  var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nullableValue);
741
741
 
742
- // node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Array.js
742
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Record.js
743
+ var map2 = /* @__PURE__ */ dual(2, (self, f) => {
744
+ const out = {
745
+ ...self
746
+ };
747
+ for (const key of keys(self)) {
748
+ out[key] = f(self[key], key);
749
+ }
750
+ return out;
751
+ });
752
+ var keys = (self) => Object.keys(self);
753
+
754
+ // node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Array.js
743
755
  var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
744
756
  var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
745
757
  var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
@@ -777,7 +789,7 @@ var intersectionWith = (isEquivalent) => {
777
789
  };
778
790
  var intersection = /* @__PURE__ */ intersectionWith(_equivalence);
779
791
  var empty = () => [];
780
- var map2 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
792
+ var map3 = /* @__PURE__ */ dual(2, (self, f) => self.map(f));
781
793
  var flatMap = /* @__PURE__ */ dual(2, (self, f) => {
782
794
  if (isEmptyReadonlyArray(self)) {
783
795
  return [];
@@ -915,6 +927,7 @@ var NanoFiber = class {
915
927
  _yielded = void 0;
916
928
  _services = {};
917
929
  _cache = {};
930
+ _perf = false;
918
931
  runLoop(nano) {
919
932
  let current = nano;
920
933
  while (true) {
@@ -938,6 +951,34 @@ var NanoFiber = class {
938
951
  return NanoYield;
939
952
  }
940
953
  };
954
+ var timings = {};
955
+ var timingsCount = {};
956
+ var WithSpanProto = {
957
+ ...PrimitiveProto,
958
+ [evaluate](fiber) {
959
+ const [fa, name] = this[args];
960
+ if (!fiber._perf) return fa;
961
+ const start = performance.now();
962
+ timingsCount[name] = (timingsCount[name] || 0) + 1;
963
+ return match(fa, {
964
+ onSuccess: (_) => {
965
+ const end = performance.now();
966
+ timings[name] = (timings[name] || 0) + (end - start);
967
+ return succeed(_);
968
+ },
969
+ onFailure: (_) => {
970
+ const end = performance.now();
971
+ timings[name] = (timings[name] || 0) + (end - start);
972
+ return fail(_);
973
+ }
974
+ });
975
+ }
976
+ };
977
+ var withSpan = (name) => (fa) => {
978
+ const nano = Object.create(WithSpanProto);
979
+ nano[args] = [fa, name];
980
+ return nano;
981
+ };
941
982
  var unsafeRun = (nano) => {
942
983
  const fiber = new NanoFiber();
943
984
  const result = fiber.runLoop(nano);
@@ -966,7 +1007,7 @@ var flatMap2 = dual(2, (fa, f) => {
966
1007
  nano[contA] = f;
967
1008
  return nano;
968
1009
  });
969
- var map3 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed(f(_))));
1010
+ var map4 = dual(2, (fa, f) => flatMap2(fa, (_) => succeed(f(_))));
970
1011
  var SyncProto = {
971
1012
  ...PrimitiveProto,
972
1013
  [evaluate](fiber) {
@@ -999,7 +1040,7 @@ var unsafeFromIterator = (iterator, initial) => {
999
1040
  return nano;
1000
1041
  };
1001
1042
  var gen = (...args2) => suspend(() => unsafeFromIterator(args2[0]()));
1002
- var fn = (_) => (body) => (...args2) => suspend(() => unsafeFromIterator(body(...args2)));
1043
+ var fn = (_) => (body) => (...args2) => withSpan(_)(suspend(() => unsafeFromIterator(body(...args2))));
1003
1044
  var MatchProto = {
1004
1045
  ...PrimitiveProto,
1005
1046
  [evaluate](fiber) {
@@ -1125,7 +1166,7 @@ function parseDiagnosticSeverity(config) {
1125
1166
  pipe(
1126
1167
  Object.entries(config),
1127
1168
  filter(([key, value]) => isString(key) && isString(value)),
1128
- map2(([key, value]) => [String(key).toLowerCase(), String(value).toLowerCase()]),
1169
+ map3(([key, value]) => [String(key).toLowerCase(), String(value).toLowerCase()]),
1129
1170
  filter(
1130
1171
  ([_, value]) => value === "off" || value === "error" || value === "warning" || value === "message" || value === "suggestion"
1131
1172
  )
@@ -1143,8 +1184,10 @@ var defaults = {
1143
1184
  inlays: true,
1144
1185
  allowedDuplicatedPackages: [],
1145
1186
  namespaceImportPackages: [],
1187
+ topLevelNamedReexports: "ignore",
1146
1188
  barrelImportPackages: [],
1147
- topLevelNamedReexports: "ignore"
1189
+ importAliases: {},
1190
+ renames: true
1148
1191
  };
1149
1192
  function parse(config) {
1150
1193
  return {
@@ -1159,7 +1202,9 @@ function parse(config) {
1159
1202
  allowedDuplicatedPackages: isObject(config) && hasProperty(config, "allowedDuplicatedPackages") && isArray(config.allowedDuplicatedPackages) && config.allowedDuplicatedPackages.every(isString) ? config.allowedDuplicatedPackages.map((_) => _.toLowerCase()) : defaults.allowedDuplicatedPackages,
1160
1203
  namespaceImportPackages: isObject(config) && hasProperty(config, "namespaceImportPackages") && isArray(config.namespaceImportPackages) && config.namespaceImportPackages.every(isString) ? config.namespaceImportPackages.map((_) => _.toLowerCase()) : defaults.namespaceImportPackages,
1161
1204
  barrelImportPackages: isObject(config) && hasProperty(config, "barrelImportPackages") && isArray(config.barrelImportPackages) && config.barrelImportPackages.every(isString) ? config.barrelImportPackages.map((_) => _.toLowerCase()) : defaults.barrelImportPackages,
1162
- topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports
1205
+ importAliases: isObject(config) && hasProperty(config, "importAliases") && isRecord(config.importAliases) ? map2(config.importAliases, (value) => String(value)) : defaults.importAliases,
1206
+ topLevelNamedReexports: isObject(config) && hasProperty(config, "topLevelNamedReexports") && isString(config.topLevelNamedReexports) && ["ignore", "follow"].includes(config.topLevelNamedReexports.toLowerCase()) ? config.topLevelNamedReexports.toLowerCase() : defaults.topLevelNamedReexports,
1207
+ renames: isObject(config) && hasProperty(config, "renames") && isBoolean(config.renames) ? config.renames : defaults.renames
1163
1208
  };
1164
1209
  }
1165
1210
 
@@ -1223,7 +1268,7 @@ function makeTypeScriptUtils(ts) {
1223
1268
  return pipe(
1224
1269
  referencedPackages.concat(packageJsonScope?.referencedPackages || []),
1225
1270
  dedupe,
1226
- map2((packageName) => packageName.toLowerCase()),
1271
+ map3((packageName) => packageName.toLowerCase()),
1227
1272
  filter(
1228
1273
  (packageName) => pattern.endsWith("*") && packageName.startsWith(pattern.toLowerCase().substring(0, pattern.length - 1))
1229
1274
  )
@@ -1247,7 +1292,7 @@ function makeTypeScriptUtils(ts) {
1247
1292
  const sourceText = sourceFile.text;
1248
1293
  let result;
1249
1294
  function find(node) {
1250
- const leading = ts.getLeadingCommentRanges(sourceText, node.getFullStart());
1295
+ const leading = ts.getLeadingCommentRanges(sourceText, node.pos);
1251
1296
  if (leading) {
1252
1297
  for (const commentRange of leading) {
1253
1298
  if (commentRange.pos <= position && position < commentRange.end) {
@@ -1256,8 +1301,8 @@ function makeTypeScriptUtils(ts) {
1256
1301
  }
1257
1302
  }
1258
1303
  }
1259
- if (node.getFullStart() <= position && position < node.getEnd()) {
1260
- node.forEachChild(find);
1304
+ if (node.pos <= position && position < node.end) {
1305
+ ts.forEachChild(node, find);
1261
1306
  }
1262
1307
  }
1263
1308
  find(sourceFile);
@@ -1276,7 +1321,7 @@ function makeTypeScriptUtils(ts) {
1276
1321
  }
1277
1322
  function findNodeAtPosition(sourceFile, position) {
1278
1323
  function find(node) {
1279
- if (position >= node.getStart() && position < node.getEnd()) {
1324
+ if (position >= ts.getTokenPosOfNode(node, sourceFile) && position < node.end) {
1280
1325
  return ts.forEachChild(node, find) || node;
1281
1326
  }
1282
1327
  return void 0;
@@ -1303,7 +1348,6 @@ function makeTypeScriptUtils(ts) {
1303
1348
  return;
1304
1349
  }
1305
1350
  const startPos = token.pos === 0 ? (ts.getShebang(sourceFile.text) || "").length : token.pos;
1306
- if (startPos === 0) return;
1307
1351
  const result = ts.forEachTrailingCommentRange(sourceFile.text, startPos, isCommentInRange, pos) || ts.forEachLeadingCommentRange(sourceFile.text, startPos, isCommentInRange, pos);
1308
1352
  return result;
1309
1353
  }
@@ -1340,7 +1384,7 @@ function makeTypeScriptUtils(ts) {
1340
1384
  fnCall = ts.factory.createCallExpression(
1341
1385
  fnCall,
1342
1386
  void 0,
1343
- [ts.factory.createStringLiteral(fnName.text)]
1387
+ [ts.factory.createStringLiteral(ts.idText(fnName))]
1344
1388
  );
1345
1389
  }
1346
1390
  return tryPreserveDeclarationSemantics(
@@ -1412,7 +1456,7 @@ function makeTypeScriptUtils(ts) {
1412
1456
  if (!namedBindings) continue;
1413
1457
  if (ts.isNamespaceImport(namedBindings)) {
1414
1458
  if (test(namedBindings.name, statement.moduleSpecifier, none2())) {
1415
- return namedBindings.name.text;
1459
+ return ts.idText(namedBindings.name);
1416
1460
  }
1417
1461
  } else if (ts.isNamedImports(namedBindings)) {
1418
1462
  for (const importSpecifier of namedBindings.elements) {
@@ -1420,7 +1464,7 @@ function makeTypeScriptUtils(ts) {
1420
1464
  orElse(() => some2(importSpecifier.name))
1421
1465
  );
1422
1466
  if (test(importSpecifier.name, statement.moduleSpecifier, importProperty)) {
1423
- return importSpecifier.name.text;
1467
+ return ts.idText(importSpecifier.name);
1424
1468
  }
1425
1469
  }
1426
1470
  }
@@ -1433,7 +1477,7 @@ function makeTypeScriptUtils(ts) {
1433
1477
  if (isNone2(importProperty) && ts.isStringLiteral(fromModule) && fromModule.text === packageName + "/" + moduleName) {
1434
1478
  return true;
1435
1479
  }
1436
- if (isSome2(importProperty) && ts.isIdentifier(importProperty.value) && importProperty.value.text === moduleName && ts.isStringLiteral(fromModule) && fromModule.text === packageName) {
1480
+ if (isSome2(importProperty) && ts.isIdentifier(importProperty.value) && ts.idText(importProperty.value) === moduleName && ts.isStringLiteral(fromModule) && fromModule.text === packageName) {
1437
1481
  return true;
1438
1482
  }
1439
1483
  return false;
@@ -1508,23 +1552,26 @@ function makeTypeScriptUtils(ts) {
1508
1552
  let replacementSpan = ts.createTextSpan(position, 0);
1509
1553
  let outerNode = precedingToken;
1510
1554
  if (ts.isIdentifier(precedingToken) && precedingToken.parent && ts.isPropertyAccessExpression(precedingToken.parent)) {
1555
+ const spanStart = ts.getTokenPosOfNode(precedingToken.parent, sourceFile);
1511
1556
  replacementSpan = ts.createTextSpan(
1512
- precedingToken.parent.getStart(sourceFile),
1513
- precedingToken.end - precedingToken.parent.getStart(sourceFile)
1557
+ spanStart,
1558
+ precedingToken.end - spanStart
1514
1559
  );
1515
1560
  accessedObject = precedingToken.parent.expression;
1516
1561
  outerNode = precedingToken.parent;
1517
1562
  } else if (ts.isToken(precedingToken) && precedingToken.kind === ts.SyntaxKind.DotToken && ts.isPropertyAccessExpression(precedingToken.parent)) {
1563
+ const precedingTokenSpanStart = ts.getTokenPosOfNode(precedingToken.parent, sourceFile);
1518
1564
  replacementSpan = ts.createTextSpan(
1519
- precedingToken.parent.getStart(sourceFile),
1520
- precedingToken.end - precedingToken.parent.getStart(sourceFile)
1565
+ precedingTokenSpanStart,
1566
+ precedingToken.end - precedingTokenSpanStart
1521
1567
  );
1522
1568
  accessedObject = precedingToken.parent.expression;
1523
1569
  outerNode = precedingToken.parent;
1524
1570
  } else if (ts.isIdentifier(precedingToken) && precedingToken.parent) {
1571
+ const precedingTokenSpanStart = ts.getTokenPosOfNode(precedingToken, sourceFile);
1525
1572
  replacementSpan = ts.createTextSpan(
1526
- precedingToken.getStart(sourceFile),
1527
- precedingToken.end - precedingToken.getStart(sourceFile)
1573
+ precedingTokenSpanStart,
1574
+ precedingToken.end - precedingTokenSpanStart
1528
1575
  );
1529
1576
  accessedObject = precedingToken;
1530
1577
  outerNode = precedingToken;
@@ -1618,6 +1665,13 @@ function makeTypeScriptUtils(ts) {
1618
1665
  []
1619
1666
  );
1620
1667
  }
1668
+ function getSourceFileOfNode(current) {
1669
+ let node = current;
1670
+ while (node && node.kind !== ts.SyntaxKind.SourceFile) {
1671
+ node = node.parent;
1672
+ }
1673
+ return node;
1674
+ }
1621
1675
  return {
1622
1676
  findNodeAtPositionIncludingTrivia,
1623
1677
  parsePackageContentNameAndVersionFromScope,
@@ -1637,7 +1691,8 @@ function makeTypeScriptUtils(ts) {
1637
1691
  createEffectGenCallExpressionWithBlock,
1638
1692
  createReturnYieldStarStatement,
1639
1693
  makeGetModuleSpecifier,
1640
- parseAccessedExpressionForCompletion
1694
+ parseAccessedExpressionForCompletion,
1695
+ getSourceFileOfNode
1641
1696
  };
1642
1697
  }
1643
1698
 
@@ -1748,7 +1803,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
1748
1803
  if (foundNode) {
1749
1804
  lineOverrides[ruleName] = lineOverrides[ruleName] || [];
1750
1805
  lineOverrides[ruleName].unshift({
1751
- pos: foundNode.node.getFullStart(),
1806
+ pos: foundNode.node.pos,
1752
1807
  end: foundNode.node.end,
1753
1808
  level: ruleLevel
1754
1809
  });
@@ -1787,11 +1842,12 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
1787
1842
  service(ChangeTracker),
1788
1843
  (changeTracker) => gen(function* () {
1789
1844
  const disableAtNode = findParentStatementForDisableNextLine(node);
1790
- const { line } = ts.getLineAndCharacterOfPosition(sourceFile, disableAtNode.getStart());
1845
+ const start = ts.getTokenPosOfNode(disableAtNode, sourceFile);
1846
+ const { line } = ts.getLineAndCharacterOfPosition(sourceFile, start);
1791
1847
  changeTracker.insertCommentBeforeLine(
1792
1848
  sourceFile,
1793
1849
  line,
1794
- disableAtNode.getStart(),
1850
+ start,
1795
1851
  ` @effect-diagnostics-next-line ${rule.name}:off`
1796
1852
  );
1797
1853
  })
@@ -1814,8 +1870,8 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
1814
1870
  };
1815
1871
  const applicableDiagnostics = [];
1816
1872
  yield* rule.apply(sourceFile, (entry) => {
1817
- const range = "getEnd" in entry.location ? { pos: entry.location.getStart(sourceFile), end: entry.location.getEnd() } : entry.location;
1818
- const node = "getEnd" in entry.location ? entry.location : tsUtils.findNodeAtPositionIncludingTrivia(sourceFile, entry.location.pos);
1873
+ const range = "kind" in entry.location ? { pos: ts.getTokenPosOfNode(entry.location, sourceFile), end: entry.location.end } : entry.location;
1874
+ const node = "kind" in entry.location ? entry.location : tsUtils.findNodeAtPositionIncludingTrivia(sourceFile, entry.location.pos);
1819
1875
  applicableDiagnostics.push({
1820
1876
  range,
1821
1877
  messageText: entry.messageText,
@@ -1919,7 +1975,7 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
1919
1975
  const edit = yield* codegen.apply(sourceFile, range);
1920
1976
  const updateHashComment = pipe(
1921
1977
  service(ChangeTracker),
1922
- map3((changeTracker) => {
1978
+ map4((changeTracker) => {
1923
1979
  changeTracker.deleteRange(sourceFile, range);
1924
1980
  changeTracker.insertText(sourceFile, range.pos, `${codegen.name}:${edit.hash}`);
1925
1981
  })
@@ -1933,31 +1989,71 @@ var getEditsForCodegen = fn("LSP.getEditsForCodegen")(function* (codegens2, sour
1933
1989
  ignore: updateHashComment
1934
1990
  };
1935
1991
  });
1992
+ var getEffectLspPatchSourceFileMetadata = (sourceFile) => {
1993
+ return sourceFile["@effect-lsp-patch/metadata"];
1994
+ };
1936
1995
 
1937
1996
  // src/core/TypeCheckerApi.ts
1938
1997
  var TypeCheckerApi = Tag("TypeChecker");
1939
- var deterministicTypeOrder = gen(function* () {
1940
- const typeChecker = yield* service(TypeCheckerApi);
1941
- return make((a, b) => {
1942
- const aName = typeChecker.typeToString(a);
1943
- const bName = typeChecker.typeToString(b);
1944
- if (aName < bName) return -1;
1945
- if (aName > bName) return 1;
1946
- return 0;
1947
- });
1948
- });
1949
- var getMissingTypeEntriesInTargetType = fn(
1950
- "TypeCheckerApi.getMissingTypeEntriesInTargetType"
1951
- )(
1952
- function* (realType, expectedType) {
1998
+ function makeResolveExternalModuleName(typeChecker) {
1999
+ if (!(hasProperty(typeChecker, "resolveExternalModuleName") && isFunction(typeChecker.resolveExternalModuleName))) {
2000
+ return;
2001
+ }
2002
+ const _internal = typeChecker.resolveExternalModuleName;
2003
+ return (moduleSpecifier) => {
2004
+ return _internal(moduleSpecifier);
2005
+ };
2006
+ }
2007
+
2008
+ // src/core/TypeCheckerUtils.ts
2009
+ var TypeCheckerUtils = Tag("TypeCheckerUtils");
2010
+ var nanoLayer2 = (fa) => pipe(
2011
+ service(TypeScriptApi),
2012
+ flatMap2(
2013
+ (ts) => flatMap2(service(TypeCheckerApi), (typeChecker) => pipe(fa, provideService(TypeCheckerUtils, makeTypeCheckerUtils(ts, typeChecker))))
2014
+ )
2015
+ );
2016
+ function makeTypeCheckerUtils(ts, typeChecker) {
2017
+ function isUnion(type) {
2018
+ return !!(type.flags & ts.TypeFlags.Union);
2019
+ }
2020
+ function isIndexType(type) {
2021
+ return !!(type.flags & ts.TypeFlags.Index);
2022
+ }
2023
+ function isThisTypeParameter(type) {
2024
+ return !!(type.flags & ts.TypeFlags.TypeParameter && type.isThisType);
2025
+ }
2026
+ function getTypeParameterAtPosition(signature, pos) {
2027
+ const type = typeChecker.getParameterType(signature, pos);
2028
+ if (isIndexType(type) && isThisTypeParameter(type.type)) {
2029
+ const constraint = typeChecker.getBaseConstraintOfType(type.type);
2030
+ if (constraint) {
2031
+ return typeChecker.getIndexType(constraint);
2032
+ }
2033
+ }
2034
+ return type;
2035
+ }
2036
+ const unrollUnionMembers = (type) => {
2037
+ const result = [];
2038
+ let toTest = [type];
2039
+ while (toTest.length > 0) {
2040
+ const type2 = toTest.pop();
2041
+ if (isUnion(type2)) {
2042
+ toTest = toTest.concat(type2.types);
2043
+ } else {
2044
+ result.push(type2);
2045
+ }
2046
+ }
2047
+ return result;
2048
+ };
2049
+ const getMissingTypeEntriesInTargetType = function(realType, expectedType) {
1953
2050
  if (realType === expectedType) return [];
1954
- const typeChecker = yield* service(TypeCheckerApi);
1955
2051
  const result = [];
1956
2052
  let toTest = [realType];
1957
2053
  while (toTest.length > 0) {
1958
2054
  const type = toTest.pop();
1959
2055
  if (!type) return result;
1960
- if (type.isUnion()) {
2056
+ if (isUnion(type)) {
1961
2057
  toTest = toTest.concat(type.types);
1962
2058
  } else {
1963
2059
  const assignable = typeChecker.isTypeAssignableTo(type, expectedType);
@@ -1967,77 +2063,99 @@ var getMissingTypeEntriesInTargetType = fn(
1967
2063
  }
1968
2064
  }
1969
2065
  return result;
1970
- }
1971
- );
1972
- var CannotFindAncestorConvertibleDeclarationError = class {
1973
- constructor(node) {
1974
- this.node = node;
1975
- }
1976
- _tag = "@effect/language-service/CannotFindAncestorConvertibleDeclarationError";
1977
- };
1978
- var getAncestorConvertibleDeclaration = fn(
1979
- "TypeCheckerApi.getAncestorConvertibleDeclaration"
1980
- )(function* (node) {
1981
- const ts = yield* service(TypeScriptApi);
1982
- let current = node;
1983
- while (current) {
1984
- if (ts.isFunctionDeclaration(current) || ts.isFunctionExpression(current) || ts.isArrowFunction(current) || ts.isMethodDeclaration(current)) {
1985
- return current;
2066
+ };
2067
+ const appendToUniqueTypesMap = fn(
2068
+ "TypeCheckerUtils.appendToUniqueTypesMap"
2069
+ )(
2070
+ function* (memory, initialType, shouldExclude) {
2071
+ const newIndexes = /* @__PURE__ */ new Set();
2072
+ const knownIndexes = /* @__PURE__ */ new Set();
2073
+ let toTest = [initialType];
2074
+ while (toTest.length > 0) {
2075
+ const type = toTest.pop();
2076
+ if (!type) break;
2077
+ if (yield* shouldExclude(type)) {
2078
+ continue;
2079
+ }
2080
+ if (isUnion(type)) {
2081
+ toTest = toTest.concat(type.types);
2082
+ } else {
2083
+ const foundMatch = [];
2084
+ for (const [typeId, knownType] of memory.entries()) {
2085
+ const areSame = typeChecker.isTypeAssignableTo(knownType, type) && typeChecker.isTypeAssignableTo(type, knownType);
2086
+ if (areSame) {
2087
+ foundMatch.push(typeId);
2088
+ break;
2089
+ }
2090
+ }
2091
+ if (foundMatch.length === 0) {
2092
+ const newId = "t" + (memory.size + 1);
2093
+ memory.set(newId, type);
2094
+ newIndexes.add(newId);
2095
+ } else {
2096
+ knownIndexes.add(foundMatch[0]);
2097
+ }
2098
+ }
2099
+ }
2100
+ return {
2101
+ newIndexes,
2102
+ knownIndexes,
2103
+ allIndexes: pipe(
2104
+ fromIterable(newIndexes),
2105
+ appendAll(fromIterable(knownIndexes))
2106
+ )
2107
+ };
1986
2108
  }
1987
- current = current.parent;
1988
- }
1989
- return yield* fail(new CannotFindAncestorConvertibleDeclarationError(node));
1990
- });
1991
- var CannotInferReturnTypeFromEmptyBody = class {
1992
- constructor(declaration) {
1993
- this.declaration = declaration;
1994
- }
1995
- _tag = "@effect/language-service/CannotInferReturnTypeFromEmptyBody";
1996
- };
1997
- var CannotInferReturnType = class {
1998
- constructor(declaration) {
1999
- this.declaration = declaration;
2000
- }
2001
- _tag = "@effect/language-service/CannotInferReturnType";
2002
- };
2003
- var getInferredReturnType = fn("TypeCheckerApi.getInferredReturnType")(function* (declaration) {
2004
- const typeChecker = yield* service(TypeCheckerApi);
2005
- if (!declaration.body) {
2006
- return yield* fail(
2007
- new CannotInferReturnTypeFromEmptyBody(declaration)
2008
- );
2009
- }
2010
- let returnType;
2011
- if (typeChecker.isImplementationOfOverload(declaration)) {
2012
- const signatures = typeChecker.getTypeAtLocation(declaration).getCallSignatures();
2013
- if (signatures.length > 1) {
2014
- returnType = typeChecker.getUnionType(
2015
- signatures.map((s) => s.getReturnType()).filter((_) => !!_)
2109
+ );
2110
+ const deterministicTypeOrder = make((a, b) => {
2111
+ const aName = typeChecker.typeToString(a);
2112
+ const bName = typeChecker.typeToString(b);
2113
+ if (aName < bName) return -1;
2114
+ if (aName > bName) return 1;
2115
+ return 0;
2116
+ });
2117
+ const getAncestorConvertibleDeclaration = (node) => {
2118
+ let current = node;
2119
+ while (current) {
2120
+ if (ts.isFunctionDeclaration(current) || ts.isFunctionExpression(current) || ts.isArrowFunction(current) || ts.isMethodDeclaration(current)) {
2121
+ return current;
2122
+ }
2123
+ current = current.parent;
2124
+ }
2125
+ };
2126
+ const getInferredReturnType = (declaration) => {
2127
+ if (!declaration.body) {
2128
+ return;
2129
+ }
2130
+ let returnType;
2131
+ if (typeChecker.isImplementationOfOverload(declaration)) {
2132
+ const signatures = typeChecker.getSignaturesOfType(
2133
+ typeChecker.getTypeAtLocation(declaration),
2134
+ ts.SignatureKind.Call
2016
2135
  );
2136
+ if (signatures.length > 1) {
2137
+ returnType = typeChecker.getUnionType(
2138
+ signatures.map((s) => typeChecker.getReturnTypeOfSignature(s)).filter((_) => !!_)
2139
+ );
2140
+ }
2017
2141
  }
2018
- }
2019
- if (!returnType) {
2020
- const signature = typeChecker.getSignatureFromDeclaration(declaration);
2021
- if (signature) {
2022
- const typePredicate = typeChecker.getTypePredicateOfSignature(signature);
2023
- if (typePredicate && typePredicate.type) {
2024
- return typePredicate.type;
2025
- } else {
2026
- returnType = typeChecker.getReturnTypeOfSignature(signature);
2142
+ if (!returnType) {
2143
+ const signature = typeChecker.getSignatureFromDeclaration(declaration);
2144
+ if (signature) {
2145
+ const typePredicate = typeChecker.getTypePredicateOfSignature(signature);
2146
+ if (typePredicate && typePredicate.type) {
2147
+ return typePredicate.type;
2148
+ } else {
2149
+ returnType = typeChecker.getReturnTypeOfSignature(signature);
2150
+ }
2027
2151
  }
2028
2152
  }
2029
- }
2030
- if (!returnType) {
2031
- return yield* fail(
2032
- new CannotInferReturnType(declaration)
2033
- );
2034
- }
2035
- return returnType;
2036
- });
2037
- var expectedAndRealType = cachedBy(
2038
- fn("TypeCheckerApi.expectedAndRealType")(function* (sourceFile) {
2039
- const typeChecker = yield* service(TypeCheckerApi);
2040
- const ts = yield* service(TypeScriptApi);
2153
+ return returnType;
2154
+ };
2155
+ const expectedAndRealTypeCache = /* @__PURE__ */ new WeakMap();
2156
+ const expectedAndRealType = (sourceFile) => {
2157
+ const cached2 = expectedAndRealTypeCache.get(sourceFile);
2158
+ if (cached2) return cached2;
2041
2159
  const result = [];
2042
2160
  const nodeToVisit = [sourceFile];
2043
2161
  const appendNodeToVisit = (node) => {
@@ -2055,7 +2173,7 @@ var expectedAndRealType = cachedBy(
2055
2173
  } else if (ts.isCallExpression(node)) {
2056
2174
  const resolvedSignature = typeChecker.getResolvedSignature(node);
2057
2175
  if (resolvedSignature) {
2058
- resolvedSignature.getParameters().map((parameter, index) => {
2176
+ resolvedSignature.parameters.map((parameter, index) => {
2059
2177
  const expectedType = typeChecker.getTypeOfSymbolAtLocation(parameter, node);
2060
2178
  const realType = typeChecker.getTypeAtLocation(node.arguments[index]);
2061
2179
  result.push([
@@ -2074,11 +2192,14 @@ var expectedAndRealType = cachedBy(
2074
2192
  if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) {
2075
2193
  const type = typeChecker.getContextualType(parent.parent);
2076
2194
  if (type) {
2077
- const symbol3 = typeChecker.getPropertyOfType(type, node.text);
2078
- if (symbol3) {
2079
- const expectedType = typeChecker.getTypeOfSymbolAtLocation(symbol3, node);
2080
- const realType = typeChecker.getTypeAtLocation(node);
2081
- result.push([node, expectedType, node, realType]);
2195
+ const name = ts.isIdentifier(node) ? ts.idText(node) : ts.isStringLiteral(node) ? node.text : void 0;
2196
+ if (name) {
2197
+ const symbol3 = typeChecker.getPropertyOfType(type, name);
2198
+ if (symbol3) {
2199
+ const expectedType = typeChecker.getTypeOfSymbolAtLocation(symbol3, node);
2200
+ const realType = typeChecker.getTypeAtLocation(node);
2201
+ result.push([node, expectedType, node, realType]);
2202
+ }
2082
2203
  }
2083
2204
  }
2084
2205
  }
@@ -2092,12 +2213,12 @@ var expectedAndRealType = cachedBy(
2092
2213
  appendNodeToVisit(node.right);
2093
2214
  continue;
2094
2215
  } else if (ts.isReturnStatement(node) && node.expression) {
2095
- const parentDeclaration = yield* option(getAncestorConvertibleDeclaration(node));
2096
- if (isSome2(parentDeclaration)) {
2097
- const expectedType = yield* option(getInferredReturnType(parentDeclaration.value));
2216
+ const parentDeclaration = getAncestorConvertibleDeclaration(node);
2217
+ if (parentDeclaration) {
2218
+ const expectedType = getInferredReturnType(parentDeclaration);
2098
2219
  const realType = typeChecker.getTypeAtLocation(node.expression);
2099
- if (isSome2(expectedType)) {
2100
- result.push([node, expectedType.value, node, realType]);
2220
+ if (expectedType) {
2221
+ result.push([node, expectedType, node, realType]);
2101
2222
  }
2102
2223
  }
2103
2224
  ts.forEachChild(node, appendNodeToVisit);
@@ -2113,10 +2234,10 @@ var expectedAndRealType = cachedBy(
2113
2234
  continue;
2114
2235
  } else if (ts.isArrowFunction(node) && (node.typeParameters || []).length > 0 && ts.isExpression(node.body)) {
2115
2236
  const body = node.body;
2116
- const expectedType = yield* option(getInferredReturnType(node));
2237
+ const expectedType = getInferredReturnType(node);
2117
2238
  const realType = typeChecker.getTypeAtLocation(body);
2118
- if (isSome2(expectedType)) {
2119
- result.push([body, expectedType.value, body, realType]);
2239
+ if (expectedType) {
2240
+ result.push([body, expectedType, body, realType]);
2120
2241
  }
2121
2242
  ts.forEachChild(body, appendNodeToVisit);
2122
2243
  continue;
@@ -2129,87 +2250,31 @@ var expectedAndRealType = cachedBy(
2129
2250
  }
2130
2251
  ts.forEachChild(node, appendNodeToVisit);
2131
2252
  }
2253
+ expectedAndRealTypeCache.set(sourceFile, result);
2132
2254
  return result;
2133
- }),
2134
- "TypeCheckerApi.expectedAndRealType",
2135
- (sourceFile) => sourceFile
2136
- );
2137
- var unrollUnionMembers = (type) => {
2138
- const result = [];
2139
- let toTest = [type];
2140
- while (toTest.length > 0) {
2141
- const type2 = toTest.pop();
2142
- if (type2.isUnion()) {
2143
- toTest = toTest.concat(type2.types);
2144
- } else {
2145
- result.push(type2);
2146
- }
2147
- }
2148
- return result;
2149
- };
2150
- var appendToUniqueTypesMap = fn(
2151
- "TypeCheckerApi.appendToUniqueTypesMap"
2152
- )(
2153
- function* (memory, initialType, shouldExclude) {
2154
- const typeChecker = yield* service(TypeCheckerApi);
2155
- const newIndexes = /* @__PURE__ */ new Set();
2156
- const knownIndexes = /* @__PURE__ */ new Set();
2157
- let toTest = [initialType];
2158
- while (toTest.length > 0) {
2159
- const type = toTest.pop();
2160
- if (!type) break;
2161
- if (yield* shouldExclude(type)) {
2162
- continue;
2163
- }
2164
- if (type.isUnion()) {
2165
- toTest = toTest.concat(type.types);
2166
- } else {
2167
- const foundMatch = [];
2168
- for (const [typeId, knownType] of memory.entries()) {
2169
- const areSame = typeChecker.isTypeAssignableTo(knownType, type) && typeChecker.isTypeAssignableTo(type, knownType);
2170
- if (areSame) {
2171
- foundMatch.push(typeId);
2172
- break;
2173
- }
2174
- }
2175
- if (foundMatch.length === 0) {
2176
- const newId = "t" + (memory.size + 1);
2177
- memory.set(newId, type);
2178
- newIndexes.add(newId);
2179
- } else {
2180
- knownIndexes.add(foundMatch[0]);
2181
- }
2182
- }
2183
- }
2184
- return {
2185
- newIndexes,
2186
- knownIndexes,
2187
- allIndexes: pipe(
2188
- fromIterable(newIndexes),
2189
- appendAll(fromIterable(knownIndexes))
2190
- )
2191
- };
2192
- }
2193
- );
2194
- function makeResolveExternalModuleName(typeChecker) {
2195
- if (!(hasProperty(typeChecker, "resolveExternalModuleName") && isFunction(typeChecker.resolveExternalModuleName))) {
2196
- return;
2197
- }
2198
- const _internal = typeChecker.resolveExternalModuleName;
2199
- return (moduleSpecifier) => {
2200
- return _internal(moduleSpecifier);
2255
+ };
2256
+ return {
2257
+ isUnion,
2258
+ getTypeParameterAtPosition,
2259
+ getMissingTypeEntriesInTargetType,
2260
+ unrollUnionMembers,
2261
+ appendToUniqueTypesMap,
2262
+ deterministicTypeOrder,
2263
+ getInferredReturnType,
2264
+ expectedAndRealType
2201
2265
  };
2202
2266
  }
2203
2267
 
2204
2268
  // src/core/TypeParser.ts
2205
2269
  var TypeParser = Tag("@effect/language-service/TypeParser");
2206
- var nanoLayer2 = (fa) => gen(function* () {
2270
+ var nanoLayer3 = (fa) => gen(function* () {
2207
2271
  const ts = yield* service(TypeScriptApi);
2208
2272
  const tsUtils = yield* service(TypeScriptUtils);
2209
2273
  const typeChecker = yield* service(TypeCheckerApi);
2274
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
2210
2275
  return yield* pipe(
2211
2276
  fa,
2212
- provideService(TypeParser, make2(ts, tsUtils, typeChecker))
2277
+ provideService(TypeParser, make2(ts, tsUtils, typeChecker, typeCheckerUtils))
2213
2278
  );
2214
2279
  });
2215
2280
  var TypeParserIssue = class _TypeParserIssue {
@@ -2219,27 +2284,27 @@ var TypeParserIssue = class _TypeParserIssue {
2219
2284
  function typeParserIssue(_message, _type, _node) {
2220
2285
  return TypeParserIssue.issue;
2221
2286
  }
2222
- function make2(ts, tsUtils, typeChecker) {
2287
+ function make2(ts, tsUtils, typeChecker, typeCheckerUtils) {
2223
2288
  function covariantTypeArgument(type) {
2224
- const signatures = type.getCallSignatures();
2289
+ const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
2225
2290
  if (signatures.length !== 1) {
2226
2291
  return typeParserIssue("Covariant type has no call signature", type);
2227
2292
  }
2228
- return succeed(signatures[0].getReturnType());
2293
+ return succeed(typeChecker.getReturnTypeOfSignature(signatures[0]));
2229
2294
  }
2230
2295
  function contravariantTypeArgument(type) {
2231
- const signatures = type.getCallSignatures();
2296
+ const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
2232
2297
  if (signatures.length !== 1) {
2233
2298
  return typeParserIssue("Contravariant type has no call signature", type);
2234
2299
  }
2235
- return succeed(signatures[0].getTypeParameterAtPosition(0));
2300
+ return succeed(typeCheckerUtils.getTypeParameterAtPosition(signatures[0], 0));
2236
2301
  }
2237
2302
  function invariantTypeArgument(type) {
2238
- const signatures = type.getCallSignatures();
2303
+ const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
2239
2304
  if (signatures.length !== 1) {
2240
2305
  return typeParserIssue("Invariant type has no call signature", type);
2241
2306
  }
2242
- return succeed(signatures[0].getReturnType());
2307
+ return succeed(typeChecker.getReturnTypeOfSignature(signatures[0]));
2243
2308
  }
2244
2309
  const pipeableType = cachedBy(
2245
2310
  function(type, atLocation) {
@@ -2248,7 +2313,7 @@ function make2(ts, tsUtils, typeChecker) {
2248
2313
  return typeParserIssue("Type has no 'pipe' property", type, atLocation);
2249
2314
  }
2250
2315
  const pipeType = typeChecker.getTypeOfSymbolAtLocation(pipeSymbol, atLocation);
2251
- const signatures = pipeType.getCallSignatures();
2316
+ const signatures = typeChecker.getSignaturesOfType(pipeType, ts.SignatureKind.Call);
2252
2317
  if (signatures.length === 0) {
2253
2318
  return typeParserIssue("'pipe' property is not callable", type, atLocation);
2254
2319
  }
@@ -2281,7 +2346,7 @@ function make2(ts, tsUtils, typeChecker) {
2281
2346
  const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
2282
2347
  return invariantTypeArgument(propertyType);
2283
2348
  };
2284
- const effectVarianceStruct = (type, atLocation) => map3(
2349
+ const effectVarianceStruct = (type, atLocation) => map4(
2285
2350
  all(
2286
2351
  varianceStructCovariantType(type, atLocation, "_A"),
2287
2352
  varianceStructCovariantType(type, atLocation, "_E"),
@@ -2289,7 +2354,7 @@ function make2(ts, tsUtils, typeChecker) {
2289
2354
  ),
2290
2355
  ([A, E, R]) => ({ A, E, R })
2291
2356
  );
2292
- const layerVarianceStruct = (type, atLocation) => map3(
2357
+ const layerVarianceStruct = (type, atLocation) => map4(
2293
2358
  all(
2294
2359
  varianceStructContravariantType(type, atLocation, "_ROut"),
2295
2360
  varianceStructCovariantType(type, atLocation, "_E"),
@@ -2303,7 +2368,9 @@ function make2(ts, tsUtils, typeChecker) {
2303
2368
  const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
2304
2369
  (_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration && ts.isPropertySignature(_.valueDeclaration) && ts.isComputedPropertyName(_.valueDeclaration.name)
2305
2370
  );
2306
- propertiesSymbols.sort((a, b) => b.name.indexOf("EffectTypeId") - a.name.indexOf("EffectTypeId"));
2371
+ propertiesSymbols.sort(
2372
+ (a, b) => ts.symbolName(b).indexOf("EffectTypeId") - ts.symbolName(a).indexOf("EffectTypeId")
2373
+ );
2307
2374
  for (const propertySymbol of propertiesSymbols) {
2308
2375
  const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
2309
2376
  result = pipe(result, orElse2(() => effectVarianceStruct(propertyType, atLocation)));
@@ -2315,7 +2382,7 @@ function make2(ts, tsUtils, typeChecker) {
2315
2382
  );
2316
2383
  const strictEffectType = cachedBy(
2317
2384
  fn("TypeParser.strictEffectType")(function* (type, atLocation) {
2318
- if (!(type.symbol && type.symbol.name === "Effect" && !type.aliasSymbol)) {
2385
+ if (!(type.symbol && ts.symbolName(type.symbol) === "Effect" && !type.aliasSymbol)) {
2319
2386
  return yield* typeParserIssue("Type name should be Effect with no alias symbol", type, atLocation);
2320
2387
  }
2321
2388
  return yield* effectType(type, atLocation);
@@ -2329,7 +2396,9 @@ function make2(ts, tsUtils, typeChecker) {
2329
2396
  const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
2330
2397
  (_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration && ts.isPropertySignature(_.valueDeclaration) && ts.isComputedPropertyName(_.valueDeclaration.name)
2331
2398
  );
2332
- propertiesSymbols.sort((a, b) => b.name.indexOf("LayerTypeId") - a.name.indexOf("LayerTypeId"));
2399
+ propertiesSymbols.sort(
2400
+ (a, b) => ts.symbolName(b).indexOf("LayerTypeId") - ts.symbolName(a).indexOf("LayerTypeId")
2401
+ );
2333
2402
  for (const propertySymbol of propertiesSymbols) {
2334
2403
  const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
2335
2404
  const varianceArgs = yield* option(layerVarianceStruct(
@@ -2424,6 +2493,21 @@ function make2(ts, tsUtils, typeChecker) {
2424
2493
  "TypeParser.importedEffectModule",
2425
2494
  (node) => node
2426
2495
  );
2496
+ const importedDataModule = cachedBy(
2497
+ fn("TypeParser.importedDataModule")(function* (node) {
2498
+ const type = typeChecker.getTypeAtLocation(node);
2499
+ const propertySymbol = typeChecker.getPropertyOfType(type, "TaggedError");
2500
+ if (!propertySymbol) {
2501
+ return yield* typeParserIssue("Type has no 'TaggedError' property", type, node);
2502
+ }
2503
+ if (!ts.isExpression(node)) {
2504
+ return yield* typeParserIssue("Node is not an expression", type, node);
2505
+ }
2506
+ return node;
2507
+ }),
2508
+ "TypeParser.importedDataModule",
2509
+ (node) => node
2510
+ );
2427
2511
  const effectGen = cachedBy(
2428
2512
  function(node) {
2429
2513
  if (!ts.isCallExpression(node)) {
@@ -2443,12 +2527,12 @@ function make2(ts, tsUtils, typeChecker) {
2443
2527
  return typeParserIssue("Node is not a property access expression", void 0, node);
2444
2528
  }
2445
2529
  const propertyAccess = node.expression;
2446
- if (propertyAccess.name.text !== "gen") {
2530
+ if (!(ts.isIdentifier(propertyAccess.name) && ts.idText(propertyAccess.name) === "gen")) {
2447
2531
  return typeParserIssue("Call expression name is not 'gen'", void 0, node);
2448
2532
  }
2449
2533
  return pipe(
2450
2534
  importedEffectModule(propertyAccess.expression),
2451
- map3((effectModule) => ({
2535
+ map4((effectModule) => ({
2452
2536
  node,
2453
2537
  effectModule,
2454
2538
  generatorFunction,
@@ -2487,7 +2571,7 @@ function make2(ts, tsUtils, typeChecker) {
2487
2571
  );
2488
2572
  }
2489
2573
  const propertyAccess = node.expression;
2490
- if (propertyAccess.name.text !== "fnUntraced") {
2574
+ if (!(ts.isIdentifier(propertyAccess.name) && ts.idText(propertyAccess.name) === "fnUntraced")) {
2491
2575
  return typeParserIssue(
2492
2576
  "Call expression name is not 'fnUntraced'",
2493
2577
  void 0,
@@ -2496,7 +2580,7 @@ function make2(ts, tsUtils, typeChecker) {
2496
2580
  }
2497
2581
  return pipe(
2498
2582
  importedEffectModule(propertyAccess.expression),
2499
- map3((effectModule) => ({
2583
+ map4((effectModule) => ({
2500
2584
  node,
2501
2585
  effectModule,
2502
2586
  generatorFunction,
@@ -2540,7 +2624,7 @@ function make2(ts, tsUtils, typeChecker) {
2540
2624
  );
2541
2625
  }
2542
2626
  const propertyAccess = expressionToTest;
2543
- if (propertyAccess.name.text !== "fn") {
2627
+ if (!(ts.isIdentifier(propertyAccess.name) && ts.idText(propertyAccess.name) === "fn")) {
2544
2628
  return typeParserIssue(
2545
2629
  "Call expression name is not 'fn'",
2546
2630
  void 0,
@@ -2549,7 +2633,7 @@ function make2(ts, tsUtils, typeChecker) {
2549
2633
  }
2550
2634
  return pipe(
2551
2635
  importedEffectModule(propertyAccess.expression),
2552
- map3((effectModule) => ({
2636
+ map4((effectModule) => ({
2553
2637
  node,
2554
2638
  generatorFunction,
2555
2639
  effectModule,
@@ -2623,7 +2707,7 @@ function make2(ts, tsUtils, typeChecker) {
2623
2707
  "TypeParser.unnecessaryEffectGen",
2624
2708
  (node) => node
2625
2709
  );
2626
- const effectSchemaVarianceStruct = (type, atLocation) => map3(
2710
+ const effectSchemaVarianceStruct = (type, atLocation) => map4(
2627
2711
  all(
2628
2712
  varianceStructInvariantType(type, atLocation, "_A"),
2629
2713
  varianceStructInvariantType(type, atLocation, "_I"),
@@ -2639,7 +2723,7 @@ function make2(ts, tsUtils, typeChecker) {
2639
2723
  const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
2640
2724
  (_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration && ts.isPropertySignature(_.valueDeclaration) && ts.isComputedPropertyName(_.valueDeclaration.name)
2641
2725
  );
2642
- propertiesSymbols.sort((a, b) => b.name.indexOf("TypeId") - a.name.indexOf("TypeId"));
2726
+ propertiesSymbols.sort((a, b) => ts.symbolName(b).indexOf("TypeId") - ts.symbolName(a).indexOf("TypeId"));
2643
2727
  for (const propertySymbol of propertiesSymbols) {
2644
2728
  const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
2645
2729
  const varianceArgs = yield* option(effectSchemaVarianceStruct(
@@ -2655,7 +2739,7 @@ function make2(ts, tsUtils, typeChecker) {
2655
2739
  "TypeParser.effectSchemaType",
2656
2740
  (type) => type
2657
2741
  );
2658
- const contextTagVarianceStruct = (type, atLocation) => map3(
2742
+ const contextTagVarianceStruct = (type, atLocation) => map4(
2659
2743
  all(
2660
2744
  varianceStructInvariantType(type, atLocation, "_Identifier"),
2661
2745
  varianceStructInvariantType(type, atLocation, "_Service")
@@ -2668,7 +2752,7 @@ function make2(ts, tsUtils, typeChecker) {
2668
2752
  const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
2669
2753
  (_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration && ts.isPropertySignature(_.valueDeclaration) && ts.isComputedPropertyName(_.valueDeclaration.name)
2670
2754
  );
2671
- propertiesSymbols.sort((a, b) => b.name.indexOf("TypeId") - a.name.indexOf("TypeId"));
2755
+ propertiesSymbols.sort((a, b) => ts.symbolName(b).indexOf("TypeId") - ts.symbolName(a).indexOf("TypeId"));
2672
2756
  for (const propertySymbol of propertiesSymbols) {
2673
2757
  const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
2674
2758
  const varianceArgs = yield* option(contextTagVarianceStruct(
@@ -2686,7 +2770,7 @@ function make2(ts, tsUtils, typeChecker) {
2686
2770
  );
2687
2771
  const pipeCall = cachedBy(
2688
2772
  function(node) {
2689
- if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && node.expression.name.text === "pipe") {
2773
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && ts.idText(node.expression.name) === "pipe") {
2690
2774
  return succeed({
2691
2775
  node,
2692
2776
  subject: node.expression.expression,
@@ -2694,7 +2778,7 @@ function make2(ts, tsUtils, typeChecker) {
2694
2778
  kind: "pipeable"
2695
2779
  });
2696
2780
  }
2697
- if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "pipe" && node.arguments.length > 0) {
2781
+ if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && ts.idText(node.expression) === "pipe" && node.arguments.length > 0) {
2698
2782
  const [subject, ...args2] = node.arguments;
2699
2783
  return succeed({ node, subject, args: args2, kind: "pipe" });
2700
2784
  }
@@ -2709,11 +2793,13 @@ function make2(ts, tsUtils, typeChecker) {
2709
2793
  const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
2710
2794
  (_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration && ts.isPropertySignature(_.valueDeclaration) && ts.isComputedPropertyName(_.valueDeclaration.name)
2711
2795
  );
2712
- propertiesSymbols.sort((a, b) => b.name.indexOf("ScopeTypeId") - a.name.indexOf("ScopeTypeId"));
2796
+ propertiesSymbols.sort(
2797
+ (a, b) => ts.symbolName(b).indexOf("ScopeTypeId") - ts.symbolName(a).indexOf("ScopeTypeId")
2798
+ );
2713
2799
  for (const propertySymbol of propertiesSymbols) {
2714
2800
  const computedPropertyExpression = propertySymbol.valueDeclaration.name;
2715
2801
  const symbol3 = typeChecker.getSymbolAtLocation(computedPropertyExpression.expression);
2716
- if (symbol3 && symbol3.name === "ScopeTypeId") {
2802
+ if (symbol3 && ts.symbolName(symbol3) === "ScopeTypeId") {
2717
2803
  return type;
2718
2804
  }
2719
2805
  }
@@ -2728,19 +2814,19 @@ function make2(ts, tsUtils, typeChecker) {
2728
2814
  if (!thenProperty) return typeParserIssue("not a promise - missing then property", type, atLocation);
2729
2815
  const thenType = typeChecker.getTypeOfSymbolAtLocation(thenProperty, atLocation);
2730
2816
  if (!thenType) return typeParserIssue("not a promise - missing then property", type, atLocation);
2731
- for (const callSignature of thenType.getCallSignatures()) {
2817
+ for (const callSignature of typeChecker.getSignaturesOfType(thenType, ts.SignatureKind.Call)) {
2732
2818
  const parameter = callSignature.parameters[0];
2733
2819
  if (!parameter) continue;
2734
- const parameterType = callSignature.getTypeParameterAtPosition(0);
2820
+ const parameterType = typeCheckerUtils.getTypeParameterAtPosition(callSignature, 0);
2735
2821
  if (!parameterType) continue;
2736
2822
  let callbackCallSignatures = [];
2737
2823
  let toTest = [parameterType];
2738
2824
  while (toTest.length > 0) {
2739
2825
  const type2 = toTest.shift();
2740
2826
  if (!type2) continue;
2741
- const callSignatures = type2.getCallSignatures();
2827
+ const callSignatures = typeChecker.getSignaturesOfType(type2, ts.SignatureKind.Call);
2742
2828
  callbackCallSignatures = callbackCallSignatures.concat(callSignatures);
2743
- if (type2.isUnion()) {
2829
+ if (typeCheckerUtils.isUnion(type2)) {
2744
2830
  toTest = toTest.concat(type2.types);
2745
2831
  }
2746
2832
  }
@@ -2749,7 +2835,7 @@ function make2(ts, tsUtils, typeChecker) {
2749
2835
  if (!callbackParameter) {
2750
2836
  continue;
2751
2837
  }
2752
- const callbackParameterType = callableType.getTypeParameterAtPosition(0);
2838
+ const callbackParameterType = typeCheckerUtils.getTypeParameterAtPosition(callableType, 0);
2753
2839
  if (!callbackParameterType) {
2754
2840
  continue;
2755
2841
  }
@@ -2781,7 +2867,7 @@ function make2(ts, tsUtils, typeChecker) {
2781
2867
  if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
2782
2868
  const selfTypeNode = schemaCall.typeArguments[0];
2783
2869
  const schemaIdentifier = schemaCall.expression;
2784
- if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && schemaIdentifier.name.text === "Class") {
2870
+ if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && ts.idText(schemaIdentifier.name) === "Class") {
2785
2871
  const parsedSchemaModule = yield* pipe(
2786
2872
  importedSchemaModule(schemaIdentifier.expression),
2787
2873
  option
@@ -2817,25 +2903,24 @@ function make2(ts, tsUtils, typeChecker) {
2817
2903
  for (const typeX of heritageClause.types) {
2818
2904
  if (ts.isExpressionWithTypeArguments(typeX)) {
2819
2905
  const expression = typeX.expression;
2820
- if (ts.isCallExpression(expression)) {
2821
- const tagCall = expression.expression;
2822
- if (ts.isCallExpression(tagCall)) {
2823
- const schemaCall = tagCall.expression;
2824
- if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
2825
- const selfTypeNode = schemaCall.typeArguments[0];
2826
- const schemaIdentifier = schemaCall.expression;
2827
- if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && schemaIdentifier.name.text === "TaggedClass") {
2828
- const parsedSchemaModule = yield* pipe(
2829
- importedSchemaModule(schemaIdentifier.expression),
2830
- option
2831
- );
2832
- if (isSome2(parsedSchemaModule)) {
2833
- return {
2834
- className: atLocation.name,
2835
- selfTypeNode,
2836
- Schema: parsedSchemaModule.value
2837
- };
2838
- }
2906
+ if (ts.isCallExpression(expression) && expression.arguments.length > 0) {
2907
+ const schemaTaggedClassTCall = expression.expression;
2908
+ if (ts.isCallExpression(schemaTaggedClassTCall) && schemaTaggedClassTCall.typeArguments && schemaTaggedClassTCall.typeArguments.length > 0) {
2909
+ const selfTypeNode = schemaTaggedClassTCall.typeArguments[0];
2910
+ const schemaIdentifier = schemaTaggedClassTCall.expression;
2911
+ if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && ts.idText(schemaIdentifier.name) === "TaggedClass") {
2912
+ const parsedSchemaModule = yield* pipe(
2913
+ importedSchemaModule(schemaIdentifier.expression),
2914
+ option
2915
+ );
2916
+ if (isSome2(parsedSchemaModule)) {
2917
+ return {
2918
+ className: atLocation.name,
2919
+ selfTypeNode,
2920
+ keyStringLiteral: schemaTaggedClassTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedClassTCall.arguments[0]) ? schemaTaggedClassTCall.arguments[0] : void 0,
2921
+ tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0,
2922
+ Schema: parsedSchemaModule.value
2923
+ };
2839
2924
  }
2840
2925
  }
2841
2926
  }
@@ -2862,24 +2947,23 @@ function make2(ts, tsUtils, typeChecker) {
2862
2947
  if (ts.isExpressionWithTypeArguments(typeX)) {
2863
2948
  const expression = typeX.expression;
2864
2949
  if (ts.isCallExpression(expression)) {
2865
- const tagCall = expression.expression;
2866
- if (ts.isCallExpression(tagCall)) {
2867
- const schemaCall = tagCall.expression;
2868
- if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
2869
- const selfTypeNode = schemaCall.typeArguments[0];
2870
- const schemaIdentifier = schemaCall.expression;
2871
- if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && schemaIdentifier.name.text === "TaggedError") {
2872
- const parsedSchemaModule = yield* pipe(
2873
- importedSchemaModule(schemaIdentifier.expression),
2874
- option
2875
- );
2876
- if (isSome2(parsedSchemaModule)) {
2877
- return {
2878
- className: atLocation.name,
2879
- selfTypeNode,
2880
- Schema: parsedSchemaModule.value
2881
- };
2882
- }
2950
+ const schemaTaggedErrorTCall = expression.expression;
2951
+ if (ts.isCallExpression(schemaTaggedErrorTCall) && schemaTaggedErrorTCall.typeArguments && schemaTaggedErrorTCall.typeArguments.length > 0) {
2952
+ const selfTypeNode = schemaTaggedErrorTCall.typeArguments[0];
2953
+ const schemaIdentifier = schemaTaggedErrorTCall.expression;
2954
+ if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && ts.idText(schemaIdentifier.name) === "TaggedError") {
2955
+ const parsedSchemaModule = yield* pipe(
2956
+ importedSchemaModule(schemaIdentifier.expression),
2957
+ option
2958
+ );
2959
+ if (isSome2(parsedSchemaModule)) {
2960
+ return {
2961
+ className: atLocation.name,
2962
+ selfTypeNode,
2963
+ keyStringLiteral: schemaTaggedErrorTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedErrorTCall.arguments[0]) ? schemaTaggedErrorTCall.arguments[0] : void 0,
2964
+ tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0,
2965
+ Schema: parsedSchemaModule.value
2966
+ };
2883
2967
  }
2884
2968
  }
2885
2969
  }
@@ -2892,6 +2976,82 @@ function make2(ts, tsUtils, typeChecker) {
2892
2976
  "TypeParser.extendsSchemaTaggedError",
2893
2977
  (atLocation) => atLocation
2894
2978
  );
2979
+ const extendsDataTaggedError = cachedBy(
2980
+ fn("TypeParser.extendsDataTaggedError")(function* (atLocation) {
2981
+ if (!atLocation.name) {
2982
+ return yield* typeParserIssue("Class has no name", void 0, atLocation);
2983
+ }
2984
+ const heritageClauses = atLocation.heritageClauses;
2985
+ if (!heritageClauses) {
2986
+ return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
2987
+ }
2988
+ for (const heritageClause of heritageClauses) {
2989
+ for (const typeX of heritageClause.types) {
2990
+ if (ts.isExpressionWithTypeArguments(typeX)) {
2991
+ const expression = typeX.expression;
2992
+ if (ts.isCallExpression(expression)) {
2993
+ const dataTaggedErrorCall = expression;
2994
+ const dataIdentifier = dataTaggedErrorCall.expression;
2995
+ if (ts.isPropertyAccessExpression(dataIdentifier) && ts.isIdentifier(dataIdentifier.name) && ts.idText(dataIdentifier.name) === "TaggedError") {
2996
+ const parsedDataModule = yield* pipe(
2997
+ importedDataModule(dataIdentifier.expression),
2998
+ option
2999
+ );
3000
+ if (isSome2(parsedDataModule)) {
3001
+ return {
3002
+ className: atLocation.name,
3003
+ keyStringLiteral: dataTaggedErrorCall.arguments.length > 0 && ts.isStringLiteral(dataTaggedErrorCall.arguments[0]) ? dataTaggedErrorCall.arguments[0] : void 0,
3004
+ Data: parsedDataModule.value
3005
+ };
3006
+ }
3007
+ }
3008
+ }
3009
+ }
3010
+ }
3011
+ }
3012
+ return yield* typeParserIssue("Class does not extend Data.TaggedError", void 0, atLocation);
3013
+ }),
3014
+ "TypeParser.extendsDataTaggedError",
3015
+ (atLocation) => atLocation
3016
+ );
3017
+ const extendsDataTaggedClass = cachedBy(
3018
+ fn("TypeParser.extendsDataTaggedClass")(function* (atLocation) {
3019
+ if (!atLocation.name) {
3020
+ return yield* typeParserIssue("Class has no name", void 0, atLocation);
3021
+ }
3022
+ const heritageClauses = atLocation.heritageClauses;
3023
+ if (!heritageClauses) {
3024
+ return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
3025
+ }
3026
+ for (const heritageClause of heritageClauses) {
3027
+ for (const typeX of heritageClause.types) {
3028
+ if (ts.isExpressionWithTypeArguments(typeX)) {
3029
+ const expression = typeX.expression;
3030
+ if (ts.isCallExpression(expression)) {
3031
+ const dataTaggedClassCall = expression;
3032
+ const dataIdentifier = dataTaggedClassCall.expression;
3033
+ if (ts.isPropertyAccessExpression(dataIdentifier) && ts.isIdentifier(dataIdentifier.name) && ts.idText(dataIdentifier.name) === "TaggedClass") {
3034
+ const parsedDataModule = yield* pipe(
3035
+ importedDataModule(dataIdentifier.expression),
3036
+ option
3037
+ );
3038
+ if (isSome2(parsedDataModule)) {
3039
+ return {
3040
+ className: atLocation.name,
3041
+ keyStringLiteral: dataTaggedClassCall.arguments.length > 0 && ts.isStringLiteral(dataTaggedClassCall.arguments[0]) ? dataTaggedClassCall.arguments[0] : void 0,
3042
+ Data: parsedDataModule.value
3043
+ };
3044
+ }
3045
+ }
3046
+ }
3047
+ }
3048
+ }
3049
+ }
3050
+ return yield* typeParserIssue("Class does not extend Data.TaggedClass", void 0, atLocation);
3051
+ }),
3052
+ "TypeParser.extendsDataTaggedClass",
3053
+ (atLocation) => atLocation
3054
+ );
2895
3055
  const extendsSchemaTaggedRequest = cachedBy(
2896
3056
  fn("TypeParser.extendsSchemaTaggedRequest")(function* (atLocation) {
2897
3057
  if (!atLocation.name) {
@@ -2906,24 +3066,23 @@ function make2(ts, tsUtils, typeChecker) {
2906
3066
  if (ts.isExpressionWithTypeArguments(typeX)) {
2907
3067
  const expression = typeX.expression;
2908
3068
  if (ts.isCallExpression(expression)) {
2909
- const tagCall = expression.expression;
2910
- if (ts.isCallExpression(tagCall)) {
2911
- const schemaCall = tagCall.expression;
2912
- if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
2913
- const selfTypeNode = schemaCall.typeArguments[0];
2914
- const schemaIdentifier = schemaCall.expression;
2915
- if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && schemaIdentifier.name.text === "TaggedRequest") {
2916
- const parsedSchemaModule = yield* pipe(
2917
- importedSchemaModule(schemaIdentifier.expression),
2918
- option
2919
- );
2920
- if (isSome2(parsedSchemaModule)) {
2921
- return {
2922
- className: atLocation.name,
2923
- selfTypeNode,
2924
- Schema: parsedSchemaModule.value
2925
- };
2926
- }
3069
+ const schemaTaggedRequestTCall = expression.expression;
3070
+ if (ts.isCallExpression(schemaTaggedRequestTCall) && schemaTaggedRequestTCall.typeArguments && schemaTaggedRequestTCall.typeArguments.length > 0) {
3071
+ const selfTypeNode = schemaTaggedRequestTCall.typeArguments[0];
3072
+ const schemaIdentifier = schemaTaggedRequestTCall.expression;
3073
+ if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && ts.idText(schemaIdentifier.name) === "TaggedRequest") {
3074
+ const parsedSchemaModule = yield* pipe(
3075
+ importedSchemaModule(schemaIdentifier.expression),
3076
+ option
3077
+ );
3078
+ if (isSome2(parsedSchemaModule)) {
3079
+ return {
3080
+ className: atLocation.name,
3081
+ selfTypeNode,
3082
+ tagStringLiteral: expression.arguments.length > 0 && ts.isStringLiteral(expression.arguments[0]) ? expression.arguments[0] : void 0,
3083
+ keyStringLiteral: schemaTaggedRequestTCall.arguments.length > 0 && ts.isStringLiteral(schemaTaggedRequestTCall.arguments[0]) ? schemaTaggedRequestTCall.arguments[0] : void 0,
3084
+ Schema: parsedSchemaModule.value
3085
+ };
2927
3086
  }
2928
3087
  }
2929
3088
  }
@@ -2941,9 +3100,6 @@ function make2(ts, tsUtils, typeChecker) {
2941
3100
  if (!atLocation.name) {
2942
3101
  return yield* typeParserIssue("Class has no name", void 0, atLocation);
2943
3102
  }
2944
- const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
2945
- if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
2946
- const type = typeChecker.getTypeOfSymbol(classSym);
2947
3103
  const heritageClauses = atLocation.heritageClauses;
2948
3104
  if (!heritageClauses) {
2949
3105
  return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
@@ -2957,16 +3113,20 @@ function make2(ts, tsUtils, typeChecker) {
2957
3113
  if (ts.isCallExpression(contextTagCall) && wholeCall.typeArguments && wholeCall.typeArguments.length > 0) {
2958
3114
  const contextTagIdentifier = contextTagCall.expression;
2959
3115
  const selfTypeNode = wholeCall.typeArguments[0];
2960
- if (ts.isPropertyAccessExpression(contextTagIdentifier) && ts.isIdentifier(contextTagIdentifier.name) && contextTagIdentifier.name.text === "Tag") {
3116
+ if (ts.isPropertyAccessExpression(contextTagIdentifier) && ts.isIdentifier(contextTagIdentifier.name) && ts.idText(contextTagIdentifier.name) === "Tag") {
2961
3117
  const parsedContextModule = yield* pipe(
2962
3118
  importedContextModule(contextTagIdentifier.expression),
2963
3119
  option
2964
3120
  );
2965
3121
  if (isSome2(parsedContextModule)) {
3122
+ const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
3123
+ if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
3124
+ const type = typeChecker.getTypeOfSymbol(classSym);
2966
3125
  const tagType = yield* contextTag(type, atLocation);
2967
3126
  return {
2968
3127
  className: atLocation.name,
2969
3128
  selfTypeNode,
3129
+ keyStringLiteral: ts.isStringLiteral(contextTagCall.arguments[0]) ? contextTagCall.arguments[0] : void 0,
2970
3130
  args: contextTagCall.arguments,
2971
3131
  Identifier: tagType.Identifier,
2972
3132
  Tag: parsedContextModule.value
@@ -2988,9 +3148,6 @@ function make2(ts, tsUtils, typeChecker) {
2988
3148
  if (!atLocation.name) {
2989
3149
  return yield* typeParserIssue("Class has no name", void 0, atLocation);
2990
3150
  }
2991
- const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
2992
- if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
2993
- const type = typeChecker.getTypeOfSymbol(classSym);
2994
3151
  const heritageClauses = atLocation.heritageClauses;
2995
3152
  if (!heritageClauses) {
2996
3153
  return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
@@ -3004,7 +3161,10 @@ function make2(ts, tsUtils, typeChecker) {
3004
3161
  if (ts.isCallExpression(effectServiceCall) && effectServiceCall.typeArguments && effectServiceCall.typeArguments.length > 0) {
3005
3162
  const effectServiceIdentifier = effectServiceCall.expression;
3006
3163
  const selfTypeNode = effectServiceCall.typeArguments[0];
3007
- if (ts.isPropertyAccessExpression(effectServiceIdentifier) && ts.isIdentifier(effectServiceIdentifier.name) && effectServiceIdentifier.name.text === "Service") {
3164
+ if (ts.isPropertyAccessExpression(effectServiceIdentifier) && ts.isIdentifier(effectServiceIdentifier.name) && ts.idText(effectServiceIdentifier.name) === "Service") {
3165
+ const classSym = typeChecker.getSymbolAtLocation(atLocation.name);
3166
+ if (!classSym) return yield* typeParserIssue("Class has no symbol", void 0, atLocation);
3167
+ const type = typeChecker.getTypeOfSymbol(classSym);
3008
3168
  const parsedContextTag = yield* pipe(
3009
3169
  importedEffectModule(effectServiceIdentifier.expression),
3010
3170
  flatMap2(() => contextTag(type, atLocation)),
@@ -3017,10 +3177,10 @@ function make2(ts, tsUtils, typeChecker) {
3017
3177
  const args2 = wholeCall.arguments[1];
3018
3178
  if (ts.isObjectLiteralExpression(args2)) {
3019
3179
  for (const property of args2.properties) {
3020
- if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && property.name.text === "accessors" && property.initializer && property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
3180
+ if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && ts.idText(property.name) === "accessors" && property.initializer && property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
3021
3181
  accessors2 = true;
3022
3182
  }
3023
- if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && property.name.text === "dependencies" && property.initializer && ts.isArrayLiteralExpression(property.initializer)) {
3183
+ if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && ts.idText(property.name) === "dependencies" && property.initializer && ts.isArrayLiteralExpression(property.initializer)) {
3024
3184
  dependencies = property.initializer.elements;
3025
3185
  }
3026
3186
  }
@@ -3031,6 +3191,7 @@ function make2(ts, tsUtils, typeChecker) {
3031
3191
  className: atLocation.name,
3032
3192
  selfTypeNode,
3033
3193
  args: wholeCall.arguments,
3194
+ keyStringLiteral: ts.isStringLiteral(wholeCall.arguments[0]) ? wholeCall.arguments[0] : void 0,
3034
3195
  options: wholeCall.arguments[1],
3035
3196
  accessors: accessors2,
3036
3197
  dependencies
@@ -3069,6 +3230,8 @@ function make2(ts, tsUtils, typeChecker) {
3069
3230
  extendsSchemaClass,
3070
3231
  extendsSchemaTaggedClass,
3071
3232
  extendsSchemaTaggedError,
3233
+ extendsDataTaggedError,
3234
+ extendsDataTaggedClass,
3072
3235
  extendsSchemaTaggedRequest
3073
3236
  };
3074
3237
  }
@@ -3104,12 +3267,12 @@ var classSelfMismatch = createDiagnostic({
3104
3267
  let actualName = "";
3105
3268
  if (ts.isTypeReferenceNode(selfTypeNode)) {
3106
3269
  if (ts.isIdentifier(selfTypeNode.typeName)) {
3107
- actualName = selfTypeNode.typeName.text;
3270
+ actualName = ts.idText(selfTypeNode.typeName);
3108
3271
  } else if (ts.isQualifiedName(selfTypeNode.typeName)) {
3109
- actualName = selfTypeNode.typeName.right.text;
3272
+ actualName = ts.idText(selfTypeNode.typeName.right);
3110
3273
  }
3111
3274
  }
3112
- const expectedName = className.text;
3275
+ const expectedName = ts.idText(className);
3113
3276
  if (actualName !== expectedName) {
3114
3277
  report({
3115
3278
  location: selfTypeNode,
@@ -3194,19 +3357,20 @@ var effectInVoidSuccess = createDiagnostic({
3194
3357
  const ts = yield* service(TypeScriptApi);
3195
3358
  const typeChecker = yield* service(TypeCheckerApi);
3196
3359
  const typeParser = yield* service(TypeParser);
3360
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
3197
3361
  const checkForEffectInVoid = fn("effectInVoidSuccess.checkForEffectInVoid")(function* (node, expectedType, valueNode, realType) {
3198
3362
  const expectedEffect = yield* typeParser.effectType(expectedType, node);
3199
3363
  const realEffect = yield* typeParser.effectType(realType, valueNode);
3200
3364
  if (expectedEffect.A.flags & ts.TypeFlags.Void) {
3201
- const voidValueTypes = unrollUnionMembers(realEffect.A);
3365
+ const voidValueTypes = typeCheckerUtils.unrollUnionMembers(realEffect.A);
3202
3366
  const voidedEffect = yield* firstSuccessOf(
3203
- voidValueTypes.map((_) => map3(typeParser.strictEffectType(_, node), () => _))
3367
+ voidValueTypes.map((_) => map4(typeParser.strictEffectType(_, node), () => _))
3204
3368
  );
3205
3369
  return { voidedEffect };
3206
3370
  }
3207
3371
  return yield* fail(typeParserIssue("expectedEffect success is not void"));
3208
3372
  });
3209
- const entries = yield* expectedAndRealType(sourceFile);
3373
+ const entries = typeCheckerUtils.expectedAndRealType(sourceFile);
3210
3374
  for (const [node, expectedType, valueNode, realType] of entries) {
3211
3375
  if (expectedType !== realType) {
3212
3376
  yield* pipe(
@@ -3216,7 +3380,7 @@ var effectInVoidSuccess = createDiagnostic({
3216
3380
  valueNode,
3217
3381
  realType
3218
3382
  ),
3219
- map3(({ voidedEffect }) => {
3383
+ map4(({ voidedEffect }) => {
3220
3384
  report(
3221
3385
  {
3222
3386
  location: node,
@@ -3311,7 +3475,7 @@ var genericEffectServices = createDiagnostic({
3311
3475
  for (const [type, reportAt] of typesToCheck) {
3312
3476
  yield* pipe(
3313
3477
  typeParser.contextTag(type, node),
3314
- map3(() => {
3478
+ map4(() => {
3315
3479
  report({
3316
3480
  location: reportAt,
3317
3481
  messageText: `Effect Services with type parameters are not supported because they cannot be properly discriminated at runtime, which may cause unexpected behavior.`,
@@ -3360,12 +3524,14 @@ var importFromBarrel = createDiagnostic({
3360
3524
  const moduleSymbol = resolveExternalModuleName(importDeclaration.moduleSpecifier);
3361
3525
  if (!moduleSymbol) return;
3362
3526
  if (!moduleSymbol.exports) return;
3363
- const sourceFile2 = importDeclaration.getSourceFile();
3527
+ const sourceFile2 = tsUtils.getSourceFileOfNode(importDeclaration);
3528
+ if (!sourceFile2) return;
3364
3529
  const nodeForSymbol = element.propertyName || element.name;
3365
3530
  const aliasSymbol = element.name || element.propertyName;
3366
- const aliasedName = aliasSymbol.text;
3531
+ const aliasedName = ts.idText(aliasSymbol);
3367
3532
  if (!ts.isIdentifier(nodeForSymbol)) return;
3368
- const importedName = nodeForSymbol.text;
3533
+ const importedName = ts.idText(nodeForSymbol);
3534
+ if (!importedName) return;
3369
3535
  const reexportedSymbol = moduleSymbol.exports.get(ts.escapeLeadingUnderscores(importedName));
3370
3536
  if (!reexportedSymbol) return;
3371
3537
  if (!(reexportedSymbol.declarations && reexportedSymbol.declarations.length === 1)) return;
@@ -3377,7 +3543,8 @@ var importFromBarrel = createDiagnostic({
3377
3543
  const originalModuleSymbol = resolveExternalModuleName(exportDeclaration.moduleSpecifier);
3378
3544
  if (!originalModuleSymbol) return;
3379
3545
  if (!originalModuleSymbol.valueDeclaration) return;
3380
- const originalSourceFile = originalModuleSymbol.valueDeclaration.getSourceFile();
3546
+ const originalSourceFile = tsUtils.getSourceFileOfNode(originalModuleSymbol.valueDeclaration);
3547
+ if (!originalSourceFile) return;
3381
3548
  const unbarrelledFileName = getModuleSpecifier(
3382
3549
  program.getCompilerOptions(),
3383
3550
  sourceFile2,
@@ -3470,8 +3637,8 @@ var leakingRequirements = createDiagnostic({
3470
3637
  apply: fn("leakingRequirements.apply")(function* (sourceFile, report) {
3471
3638
  const ts = yield* service(TypeScriptApi);
3472
3639
  const typeChecker = yield* service(TypeCheckerApi);
3640
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
3473
3641
  const typeParser = yield* service(TypeParser);
3474
- const typeOrder = yield* deterministicTypeOrder;
3475
3642
  const parseLeakedRequirements = cachedBy(
3476
3643
  fn("leakingServices.checkServiceLeaking")(
3477
3644
  function* (service2, atLocation) {
@@ -3485,13 +3652,19 @@ var leakingRequirements = createDiagnostic({
3485
3652
  let effectContextType = void 0;
3486
3653
  yield* pipe(
3487
3654
  typeParser.effectType(servicePropertyType, atLocation),
3488
- map3((_) => effectContextType = _.R),
3655
+ map4((_) => effectContextType = _.R),
3489
3656
  orElse2(() => {
3490
- const servicePropertyCallSignatures = servicePropertyType.getCallSignatures();
3657
+ const servicePropertyCallSignatures = typeChecker.getSignaturesOfType(
3658
+ servicePropertyType,
3659
+ ts.SignatureKind.Call
3660
+ );
3491
3661
  if (servicePropertyCallSignatures.length === 1) {
3492
3662
  return pipe(
3493
- typeParser.effectType(servicePropertyCallSignatures[0].getReturnType(), atLocation),
3494
- map3((_) => {
3663
+ typeParser.effectType(
3664
+ typeChecker.getReturnTypeOfSignature(servicePropertyCallSignatures[0]),
3665
+ atLocation
3666
+ ),
3667
+ map4((_) => {
3495
3668
  effectContextType = _.R;
3496
3669
  })
3497
3670
  );
@@ -3502,14 +3675,14 @@ var leakingRequirements = createDiagnostic({
3502
3675
  );
3503
3676
  if (effectContextType) {
3504
3677
  effectMembers++;
3505
- const { allIndexes } = yield* appendToUniqueTypesMap(
3678
+ const { allIndexes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
3506
3679
  memory,
3507
3680
  effectContextType,
3508
3681
  (type) => {
3509
3682
  if (type.flags & ts.TypeFlags.Never) return succeed(true);
3510
3683
  return pipe(
3511
3684
  typeParser.scopeType(type, atLocation),
3512
- map3(() => true),
3685
+ map4(() => true),
3513
3686
  orElse2(() => succeed(false))
3514
3687
  );
3515
3688
  }
@@ -3550,7 +3723,7 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
3550
3723
  while (nodeToVisit.length > 0) {
3551
3724
  const node = nodeToVisit.shift();
3552
3725
  const typesToCheck = [];
3553
- if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && node.expression.name.text === "GenericTag") {
3726
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && ts.idText(node.expression.name) === "GenericTag") {
3554
3727
  typesToCheck.push([typeChecker.getTypeAtLocation(node), node]);
3555
3728
  } else if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
3556
3729
  const classSym = typeChecker.getSymbolAtLocation(node.name);
@@ -3568,7 +3741,9 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
3568
3741
  flatMap2(
3569
3742
  ({ Service }) => pipe(
3570
3743
  parseLeakedRequirements(Service, node),
3571
- map3((requirements) => reportLeakingRequirements(reportAt, sort(requirements, typeOrder)))
3744
+ map4(
3745
+ (requirements) => reportLeakingRequirements(reportAt, sort(requirements, typeCheckerUtils.deterministicTypeOrder))
3746
+ )
3572
3747
  )
3573
3748
  ),
3574
3749
  orElse2(() => sync(() => ts.forEachChild(node, appendNodeToVisit))),
@@ -3587,21 +3762,21 @@ var missingEffectContext = createDiagnostic({
3587
3762
  apply: fn("missingEffectContext.apply")(function* (sourceFile, report) {
3588
3763
  const typeChecker = yield* service(TypeCheckerApi);
3589
3764
  const typeParser = yield* service(TypeParser);
3590
- const typeOrder = yield* deterministicTypeOrder;
3765
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
3591
3766
  const checkForMissingContextTypes = (node, expectedType, valueNode, realType) => pipe(
3592
3767
  all(
3593
3768
  typeParser.effectType(expectedType, node),
3594
3769
  typeParser.effectType(realType, valueNode)
3595
3770
  ),
3596
- flatMap2(
3597
- ([expectedEffect, realEffect]) => getMissingTypeEntriesInTargetType(
3771
+ map4(
3772
+ ([expectedEffect, realEffect]) => typeCheckerUtils.getMissingTypeEntriesInTargetType(
3598
3773
  realEffect.R,
3599
3774
  expectedEffect.R
3600
3775
  )
3601
3776
  )
3602
3777
  );
3603
- const sortTypes = sort(typeOrder);
3604
- const entries = yield* expectedAndRealType(sourceFile);
3778
+ const sortTypes = sort(typeCheckerUtils.deterministicTypeOrder);
3779
+ const entries = getEffectLspPatchSourceFileMetadata(sourceFile)?.relationErrors || typeCheckerUtils.expectedAndRealType(sourceFile);
3605
3780
  for (const [node, expectedType, valueNode, realType] of entries) {
3606
3781
  if (expectedType !== realType) {
3607
3782
  yield* pipe(
@@ -3611,7 +3786,7 @@ var missingEffectContext = createDiagnostic({
3611
3786
  valueNode,
3612
3787
  realType
3613
3788
  ),
3614
- map3(
3789
+ map4(
3615
3790
  (missingTypes) => missingTypes.length > 0 ? report(
3616
3791
  {
3617
3792
  location: node,
@@ -3636,8 +3811,8 @@ var missingEffectError = createDiagnostic({
3636
3811
  const ts = yield* service(TypeScriptApi);
3637
3812
  const tsUtils = yield* service(TypeScriptUtils);
3638
3813
  const typeChecker = yield* service(TypeCheckerApi);
3814
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
3639
3815
  const typeParser = yield* service(TypeParser);
3640
- const typeOrder = yield* deterministicTypeOrder;
3641
3816
  const effectModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
3642
3817
  sourceFile,
3643
3818
  "effect",
@@ -3656,18 +3831,18 @@ var missingEffectError = createDiagnostic({
3656
3831
  typeParser.effectType(expectedType, node),
3657
3832
  typeParser.effectType(realType, valueNode)
3658
3833
  ),
3659
- flatMap2(
3834
+ map4(
3660
3835
  ([expectedEffect, realEffect]) => pipe(
3661
- getMissingTypeEntriesInTargetType(
3836
+ typeCheckerUtils.getMissingTypeEntriesInTargetType(
3662
3837
  realEffect.E,
3663
3838
  expectedEffect.E
3664
3839
  ),
3665
- map3((missingErrorTypes) => ({ missingErrorTypes, expectedErrorType: expectedEffect.E }))
3840
+ (missingErrorTypes) => ({ missingErrorTypes, expectedErrorType: expectedEffect.E })
3666
3841
  )
3667
3842
  )
3668
3843
  );
3669
- const sortTypes = sort(typeOrder);
3670
- const entries = yield* expectedAndRealType(sourceFile);
3844
+ const sortTypes = sort(typeCheckerUtils.deterministicTypeOrder);
3845
+ const entries = getEffectLspPatchSourceFileMetadata(sourceFile)?.relationErrors || typeCheckerUtils.expectedAndRealType(sourceFile);
3671
3846
  for (const [node, expectedType, valueNode, realType] of entries) {
3672
3847
  if (expectedType !== realType) {
3673
3848
  yield* pipe(
@@ -3677,7 +3852,7 @@ var missingEffectError = createDiagnostic({
3677
3852
  valueNode,
3678
3853
  realType
3679
3854
  ),
3680
- map3((result) => {
3855
+ map4((result) => {
3681
3856
  if (result.missingErrorTypes.length === 0) return;
3682
3857
  const fixes = [];
3683
3858
  if (ts.isExpression(valueNode) && result.expectedErrorType.flags & ts.TypeFlags.Never) {
@@ -3686,31 +3861,35 @@ var missingEffectError = createDiagnostic({
3686
3861
  description: "Catch all errors with Effect.catchAll",
3687
3862
  apply: gen(function* () {
3688
3863
  const changeTracker = yield* service(ChangeTracker);
3689
- changeTracker.insertText(sourceFile, valueNode.getStart(), effectModuleIdentifier + ".catchAll(");
3690
- changeTracker.insertText(sourceFile, valueNode.getEnd(), ", () => ");
3864
+ changeTracker.insertText(
3865
+ sourceFile,
3866
+ ts.getTokenPosOfNode(valueNode, sourceFile),
3867
+ effectModuleIdentifier + ".catchAll("
3868
+ );
3869
+ changeTracker.insertText(sourceFile, valueNode.end, ", () => ");
3691
3870
  changeTracker.insertNodeAt(
3692
3871
  sourceFile,
3693
- valueNode.getEnd(),
3872
+ valueNode.end,
3694
3873
  createDieMessage("TODO: catchAll not implemented")
3695
3874
  );
3696
- changeTracker.insertText(sourceFile, valueNode.getEnd(), ")");
3875
+ changeTracker.insertText(sourceFile, valueNode.end, ")");
3697
3876
  })
3698
3877
  });
3699
3878
  }
3700
3879
  if (ts.isExpression(valueNode)) {
3701
3880
  const propertyAssignments = pipe(
3702
3881
  result.missingErrorTypes,
3703
- map2((_) => typeChecker.getPropertyOfType(_, "_tag")),
3882
+ map3((_) => typeChecker.getPropertyOfType(_, "_tag")),
3704
3883
  filter((_) => !!_),
3705
- map2((_) => typeChecker.getTypeOfSymbolAtLocation(_, valueNode)),
3884
+ map3((_) => typeChecker.getTypeOfSymbolAtLocation(_, valueNode)),
3706
3885
  filter((_) => !!(_.flags & ts.TypeFlags.Literal)),
3707
- map2((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
3886
+ map3((_) => typeChecker.typeToTypeNode(_, void 0, ts.NodeBuilderFlags.NoTruncation)),
3708
3887
  filter((_) => !!_ && ts.isLiteralTypeNode(_)),
3709
- map2((_) => _.literal),
3888
+ map3((_) => _.literal),
3710
3889
  filter((_) => ts.isLiteralExpression(_)),
3711
- map2((_) => _.text),
3890
+ map3((_) => _.text),
3712
3891
  sort(string2),
3713
- map2(
3892
+ map3(
3714
3893
  (_) => ts.factory.createPropertyAssignment(
3715
3894
  ts.factory.createIdentifier(_),
3716
3895
  ts.factory.createArrowFunction(
@@ -3730,22 +3909,27 @@ var missingEffectError = createDiagnostic({
3730
3909
  description: "Catch unexpected errors with Effect.catchTag",
3731
3910
  apply: gen(function* () {
3732
3911
  const changeTracker = yield* service(ChangeTracker);
3733
- changeTracker.insertText(sourceFile, valueNode.getStart(), effectModuleIdentifier + ".catchTags(");
3734
- changeTracker.insertText(sourceFile, valueNode.getEnd(), ", ");
3912
+ changeTracker.insertText(
3913
+ sourceFile,
3914
+ ts.getTokenPosOfNode(valueNode, sourceFile),
3915
+ effectModuleIdentifier + ".catchTags("
3916
+ );
3917
+ changeTracker.insertText(sourceFile, valueNode.end, ", ");
3735
3918
  changeTracker.insertNodeAt(
3736
3919
  sourceFile,
3737
- valueNode.getEnd(),
3920
+ valueNode.end,
3738
3921
  ts.factory.createObjectLiteralExpression(propertyAssignments)
3739
3922
  );
3740
- changeTracker.insertText(sourceFile, valueNode.getEnd(), ")");
3923
+ changeTracker.insertText(sourceFile, valueNode.end, ")");
3741
3924
  })
3742
3925
  });
3743
3926
  }
3744
3927
  }
3928
+ const typeNames = sortTypes(result.missingErrorTypes).map((_) => typeChecker.typeToString(_));
3745
3929
  report(
3746
3930
  {
3747
3931
  location: node,
3748
- messageText: `Missing '${sortTypes(result.missingErrorTypes).map((_) => typeChecker.typeToString(_)).join(" | ")}' in the expected Effect errors.`,
3932
+ messageText: `Missing '${typeNames.join(" | ")}' in the expected Effect errors.`,
3749
3933
  fixes
3750
3934
  }
3751
3935
  );
@@ -3765,6 +3949,7 @@ var missingEffectServiceDependency = createDiagnostic({
3765
3949
  apply: fn("missingEffectServiceDependency.apply")(function* (sourceFile, report) {
3766
3950
  const ts = yield* service(TypeScriptApi);
3767
3951
  const typeChecker = yield* service(TypeCheckerApi);
3952
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
3768
3953
  const typeParser = yield* service(TypeParser);
3769
3954
  const nodeToVisit = [];
3770
3955
  const appendNodeToVisit = (node) => {
@@ -3795,7 +3980,7 @@ var missingEffectServiceDependency = createDiagnostic({
3795
3980
  if (layerResult) {
3796
3981
  const servicesMemory = /* @__PURE__ */ new Map();
3797
3982
  const excludeNever = (type) => succeed((type.flags & ts.TypeFlags.Never) !== 0);
3798
- const { allIndexes: requiredIndexes } = yield* appendToUniqueTypesMap(
3983
+ const { allIndexes: requiredIndexes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
3799
3984
  servicesMemory,
3800
3985
  layerResult.RIn,
3801
3986
  excludeNever
@@ -3806,8 +3991,8 @@ var missingEffectServiceDependency = createDiagnostic({
3806
3991
  let types = [];
3807
3992
  if (dependenciesProperty) {
3808
3993
  const dependenciesTypes = typeChecker.getTypeOfSymbolAtLocation(dependenciesProperty, options);
3809
- const numberIndexType = dependenciesTypes.getNumberIndexType();
3810
- types = numberIndexType ? unrollUnionMembers(numberIndexType) : [];
3994
+ const numberIndexType = typeChecker.getIndexTypeOfType(dependenciesTypes, ts.IndexKind.Number);
3995
+ types = numberIndexType ? typeCheckerUtils.unrollUnionMembers(numberIndexType) : [];
3811
3996
  }
3812
3997
  for (const depType of types) {
3813
3998
  const depLayerResult = yield* pipe(
@@ -3815,7 +4000,7 @@ var missingEffectServiceDependency = createDiagnostic({
3815
4000
  orElse2(() => void_)
3816
4001
  );
3817
4002
  if (depLayerResult) {
3818
- const { allIndexes } = yield* appendToUniqueTypesMap(
4003
+ const { allIndexes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
3819
4004
  servicesMemory,
3820
4005
  depLayerResult.ROut,
3821
4006
  excludeNever
@@ -3940,7 +4125,7 @@ var missingStarInYieldEffectGen = createDiagnostic({
3940
4125
  typeParser.effectGen(effectGenNode),
3941
4126
  orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
3942
4127
  orElse2(() => typeParser.effectFnGen(effectGenNode)),
3943
- map3(({ functionStar }) => {
4128
+ map4(({ functionStar }) => {
3944
4129
  if (functionStar) {
3945
4130
  brokenGenerators.add(functionStar);
3946
4131
  }
@@ -4004,13 +4189,13 @@ var multipleEffectProvide = createDiagnostic({
4004
4189
  "Layer"
4005
4190
  ) || "Layer";
4006
4191
  const parseEffectProvideLayer = (node) => {
4007
- if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && node.expression.name.text === "provide" && node.arguments.length > 0) {
4192
+ if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && ts.idText(node.expression.name) === "provide" && node.arguments.length > 0) {
4008
4193
  const layer = node.arguments[0];
4009
4194
  const type = typeChecker.getTypeAtLocation(layer);
4010
4195
  return pipe(
4011
4196
  typeParser.importedEffectModule(node.expression.expression),
4012
4197
  flatMap2(() => typeParser.layerType(type, layer)),
4013
- map3(() => ({ layer, node })),
4198
+ map4(() => ({ layer, node })),
4014
4199
  orElse2(() => void_)
4015
4200
  );
4016
4201
  }
@@ -4040,8 +4225,8 @@ var multipleEffectProvide = createDiagnostic({
4040
4225
  apply: gen(function* () {
4041
4226
  const changeTracker = yield* service(ChangeTracker);
4042
4227
  changeTracker.deleteRange(sourceFile, {
4043
- pos: chunk[0].node.getStart(sourceFile),
4044
- end: chunk[chunk.length - 1].node.getEnd()
4228
+ pos: ts.getTokenPosOfNode(chunk[0].node, sourceFile),
4229
+ end: chunk[chunk.length - 1].node.end
4045
4230
  });
4046
4231
  const newNode = ts.factory.createCallExpression(
4047
4232
  ts.factory.createPropertyAccessExpression(
@@ -4058,7 +4243,7 @@ var multipleEffectProvide = createDiagnostic({
4058
4243
  chunk.map((c) => c.layer)
4059
4244
  )]
4060
4245
  );
4061
- changeTracker.insertNodeAt(sourceFile, chunk[0].node.getStart(sourceFile), newNode);
4246
+ changeTracker.insertNodeAt(sourceFile, ts.getTokenPosOfNode(chunk[0].node, sourceFile), newNode);
4062
4247
  })
4063
4248
  }]
4064
4249
  });
@@ -4087,7 +4272,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
4087
4272
  const typeChecker = yield* service(TypeCheckerApi);
4088
4273
  const typeParser = yield* service(TypeParser);
4089
4274
  const changeTracker = yield* service(ChangeTracker);
4090
- const insertLocation = atLocation.members.length > 0 ? atLocation.members[0].pos : atLocation.getEnd() - 1;
4275
+ const insertLocation = atLocation.members.length > 0 ? atLocation.members[0].pos : atLocation.end - 1;
4091
4276
  const effectIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
4092
4277
  sourceFile,
4093
4278
  "effect",
@@ -4101,7 +4286,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
4101
4286
  ),
4102
4287
  void 0,
4103
4288
  [
4104
- ts.factory.createIdentifier(className2.text),
4289
+ ts.factory.createIdentifier(ts.idText(className2)),
4105
4290
  ts.factory.createArrowFunction(
4106
4291
  void 0,
4107
4292
  void 0,
@@ -4151,9 +4336,9 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
4151
4336
  const generateReturnType = (type, atLocation2, className2) => pipe(
4152
4337
  typeParser.effectType(type, atLocation2),
4153
4338
  flatMap2((returnedEffect) => {
4154
- const contextType = returnedEffect.R.flags & ts.TypeFlags.Never ? ts.factory.createTypeReferenceNode(className2.text) : ts.factory.createUnionTypeNode(
4339
+ const contextType = returnedEffect.R.flags & ts.TypeFlags.Never ? ts.factory.createTypeReferenceNode(ts.idText(className2)) : ts.factory.createUnionTypeNode(
4155
4340
  [
4156
- ts.factory.createTypeReferenceNode(className2.text),
4341
+ ts.factory.createTypeReferenceNode(ts.idText(className2)),
4157
4342
  typeChecker.typeToTypeNode(returnedEffect.R, atLocation2, ts.NodeBuilderFlags.NoTruncation)
4158
4343
  ]
4159
4344
  );
@@ -4201,7 +4386,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
4201
4386
  ts.factory.createIdentifier("UnknownException")
4202
4387
  )
4203
4388
  ),
4204
- ts.factory.createTypeReferenceNode(className2.text)
4389
+ ts.factory.createTypeReferenceNode(ts.idText(className2))
4205
4390
  ]
4206
4391
  ));
4207
4392
  })
@@ -4218,7 +4403,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
4218
4403
  [
4219
4404
  successType,
4220
4405
  ts.factory.createTypeReferenceNode("never"),
4221
- ts.factory.createTypeReferenceNode(className2.text)
4406
+ ts.factory.createTypeReferenceNode(ts.idText(className2))
4222
4407
  ]
4223
4408
  );
4224
4409
  return succeed(typeNode);
@@ -4232,7 +4417,11 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
4232
4417
  ts.NodeBuilderFlags.NoTruncation
4233
4418
  );
4234
4419
  if (!signatureDeclaration) return yield* fail("error generating signature");
4235
- const returnType = yield* generateReturnType(signature.getReturnType(), atLocation2, className2);
4420
+ const returnType = yield* generateReturnType(
4421
+ typeChecker.getReturnTypeOfSignature(signature),
4422
+ atLocation2,
4423
+ className2
4424
+ );
4236
4425
  return ts.factory.createFunctionTypeNode(
4237
4426
  signatureDeclaration.typeParameters,
4238
4427
  signatureDeclaration.parameters,
@@ -4242,10 +4431,10 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
4242
4431
  for (const { property, propertyType } of involvedMembers) {
4243
4432
  const callSignatures = [];
4244
4433
  let propertyDeclaration = void 0;
4245
- for (const signature of propertyType.getCallSignatures()) {
4434
+ for (const signature of typeChecker.getSignaturesOfType(propertyType, ts.SignatureKind.Call)) {
4246
4435
  yield* pipe(
4247
4436
  proxySignature(signature, atLocation, className),
4248
- map3((sig) => {
4437
+ map4((sig) => {
4249
4438
  callSignatures.push(sig);
4250
4439
  }),
4251
4440
  ignore
@@ -4253,17 +4442,18 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
4253
4442
  }
4254
4443
  const allSignatures = ts.factory.createIntersectionTypeNode(callSignatures);
4255
4444
  const type = tsUtils.simplifyTypeNode(allSignatures);
4256
- propertyDeclaration = createFunctionProperty(className, property.getName(), type, callSignatures.length > 1);
4445
+ propertyDeclaration = createFunctionProperty(className, ts.symbolName(property), type, callSignatures.length > 1);
4257
4446
  const oldProperty = atLocation.members.filter(ts.isPropertyDeclaration).find((p) => {
4258
4447
  const symbol3 = typeChecker.getSymbolAtLocation(p.name);
4259
- return symbol3?.getName() === property.getName();
4448
+ return symbol3 && ts.symbolName(symbol3) === ts.symbolName(property);
4260
4449
  });
4261
4450
  if (oldProperty) {
4451
+ const start = ts.getTokenPosOfNode(oldProperty, sourceFile);
4262
4452
  changeTracker.deleteRange(sourceFile, {
4263
- pos: oldProperty.getStart(sourceFile),
4264
- end: oldProperty.getEnd()
4453
+ pos: start,
4454
+ end: oldProperty.end
4265
4455
  });
4266
- changeTracker.insertNodeAt(sourceFile, oldProperty.getStart(sourceFile), propertyDeclaration);
4456
+ changeTracker.insertNodeAt(sourceFile, start, propertyDeclaration);
4267
4457
  } else {
4268
4458
  changeTracker.insertNodeAt(sourceFile, insertLocation, propertyDeclaration, { suffix: "\n" });
4269
4459
  }
@@ -4282,15 +4472,15 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
4282
4472
  const involvedMembers = [];
4283
4473
  for (const property of typeChecker.getPropertiesOfType(Service)) {
4284
4474
  const propertyType = typeChecker.getTypeOfSymbolAtLocation(property, node);
4285
- const callSignatures = propertyType.getCallSignatures();
4475
+ const callSignatures = typeChecker.getSignaturesOfType(propertyType, ts.SignatureKind.Call);
4286
4476
  if (callSignatures.length > 0) {
4287
4477
  const withTypeParameters = callSignatures.filter((_) => _.typeParameters && _.typeParameters.length > 0);
4288
4478
  if (callSignatures.length > 1 || withTypeParameters.length > 0) involvedMembers.push({ property, propertyType });
4289
4479
  }
4290
4480
  }
4291
4481
  const hash2 = involvedMembers.map(({ property, propertyType }) => {
4292
- return property.getName() + ": " + typeChecker.typeToString(propertyType);
4293
- }).concat([className.text]).join("\n");
4482
+ return ts.symbolName(property) + ": " + typeChecker.typeToString(propertyType);
4483
+ }).concat([ts.idText(className)]).join("\n");
4294
4484
  return { Service, className, atLocation: node, hash: cyrb53(hash2), involvedMembers };
4295
4485
  });
4296
4486
  var writeTagClassAccessors = createRefactor({
@@ -4303,7 +4493,7 @@ var writeTagClassAccessors = createRefactor({
4303
4493
  const typeParser = yield* service(TypeParser);
4304
4494
  const parseNode = (node) => pipe(
4305
4495
  parse2(node),
4306
- map3(({ Service, atLocation, className, involvedMembers }) => ({
4496
+ map4(({ Service, atLocation, className, involvedMembers }) => ({
4307
4497
  kind: "refactor.rewrite.effect.writeTagClassAccessors",
4308
4498
  description: "Implement Service accessors",
4309
4499
  apply: pipe(
@@ -4335,7 +4525,7 @@ var accessors = createCodegen({
4335
4525
  if (!nodeAndCommentRange) return yield* fail(new CodegenNotApplicableError("no node and comment range"));
4336
4526
  return yield* pipe(
4337
4527
  parse2(nodeAndCommentRange.node),
4338
- map3(
4528
+ map4(
4339
4529
  (_) => ({
4340
4530
  hash: _.hash,
4341
4531
  description: "Generate accessors for the service",
@@ -4366,7 +4556,7 @@ var outdatedEffectCodegen = createDiagnostic({
4366
4556
  for (const { codegen, hash: hash2, range } of codegensWithRanges) {
4367
4557
  yield* pipe(
4368
4558
  getEditsForCodegen([codegen], sourceFile, range),
4369
- map3((applicable) => {
4559
+ map4((applicable) => {
4370
4560
  if (applicable.hash !== hash2) {
4371
4561
  _report({
4372
4562
  location: range,
@@ -4426,7 +4616,7 @@ var overriddenSchemaConstructor = createDiagnostic({
4426
4616
  const typeAtLocation = typeChecker.getTypeAtLocation(type.expression);
4427
4617
  const isSchema = yield* pipe(
4428
4618
  typeParser.effectSchemaType(typeAtLocation, type.expression),
4429
- map3(() => true),
4619
+ map4(() => true),
4430
4620
  orElse2(() => succeed(false))
4431
4621
  );
4432
4622
  if (isSchema) {
@@ -4497,7 +4687,7 @@ var returnEffectInGen = createDiagnostic({
4497
4687
  typeParser.effectGen(effectGenNode),
4498
4688
  orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
4499
4689
  orElse2(() => typeParser.effectFnGen(effectGenNode)),
4500
- map3(() => {
4690
+ map4(() => {
4501
4691
  const fix = node.expression ? [{
4502
4692
  fixName: "returnEffectInGen_fix",
4503
4693
  description: "Add yield* statement",
@@ -4540,6 +4730,7 @@ var scopeInLayerEffect = createDiagnostic({
4540
4730
  const tsUtils = yield* service(TypeScriptUtils);
4541
4731
  const typeChecker = yield* service(TypeCheckerApi);
4542
4732
  const typeParser = yield* service(TypeParser);
4733
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
4543
4734
  const layerModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
4544
4735
  sourceFile,
4545
4736
  "effect",
@@ -4550,25 +4741,16 @@ var scopeInLayerEffect = createDiagnostic({
4550
4741
  const expression = node.expression;
4551
4742
  if (!ts.isPropertyAccessExpression(expression)) return;
4552
4743
  const calledModule = expression.expression;
4553
- if (!(ts.isIdentifier(calledModule) && calledModule.text === layerModuleIdentifier)) return;
4744
+ if (!(ts.isIdentifier(calledModule) && ts.idText(calledModule) === layerModuleIdentifier)) return;
4554
4745
  const methodIdentifier = expression.name;
4555
- if (!(ts.isIdentifier(methodIdentifier) && methodIdentifier.text.toLowerCase().startsWith("effect"))) return;
4746
+ if (!(ts.isIdentifier(methodIdentifier) && ts.idText(methodIdentifier).toLowerCase().startsWith("effect"))) return;
4556
4747
  return { methodIdentifier };
4557
4748
  }
4558
4749
  const reportIfLayerRequireScope = (type, node, methodIdentifier) => {
4559
- let toCheck = [type];
4560
- const entries = [];
4561
- while (toCheck.length > 0) {
4562
- const type2 = toCheck.pop();
4563
- if (type2.isUnion()) {
4564
- toCheck = toCheck.concat(type2.types);
4565
- } else {
4566
- entries.push(type2);
4567
- }
4568
- }
4750
+ const entries = typeCheckerUtils.unrollUnionMembers(type);
4569
4751
  return pipe(
4570
4752
  firstSuccessOf(entries.map((type2) => typeParser.scopeType(type2, node))),
4571
- map3(
4753
+ map4(
4572
4754
  () => report({
4573
4755
  location: node,
4574
4756
  messageText: `Seems like you are constructing a layer with a scope in the requirements.
@@ -4637,6 +4819,7 @@ var strictBooleanExpressions = createDiagnostic({
4637
4819
  apply: fn("strictBooleanExpressions.apply")(function* (sourceFile, report) {
4638
4820
  const ts = yield* service(TypeScriptApi);
4639
4821
  const typeChecker = yield* service(TypeCheckerApi);
4822
+ const typeCheckerUtils = yield* service(TypeCheckerUtils);
4640
4823
  const conditionChecks = /* @__PURE__ */ new WeakMap();
4641
4824
  const nodeToVisit = [];
4642
4825
  const appendNodeToVisit = (node) => {
@@ -4677,7 +4860,7 @@ var strictBooleanExpressions = createDiagnostic({
4677
4860
  let typesToCheck = [constrainedType || nodeType];
4678
4861
  while (typesToCheck.length > 0) {
4679
4862
  const type = typesToCheck.pop();
4680
- if (type.isUnion()) {
4863
+ if (typeCheckerUtils.isUnion(type)) {
4681
4864
  typesToCheck = typesToCheck.concat(type.types);
4682
4865
  continue;
4683
4866
  }
@@ -4726,7 +4909,7 @@ var tryCatchInEffectGen = createDiagnostic({
4726
4909
  typeParser.effectGen(effectGenNode),
4727
4910
  orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
4728
4911
  orElse2(() => typeParser.effectFnGen(effectGenNode)),
4729
- map3(() => {
4912
+ map4(() => {
4730
4913
  report({
4731
4914
  location: node,
4732
4915
  messageText: "Avoid using try/catch inside Effect generators. Use Effect's error handling mechanisms instead (e.g., Effect.try, Effect.tryPromise, Effect.catchAll, Effect.catchTag).",
@@ -4761,7 +4944,7 @@ var unnecessaryEffectGen = createDiagnostic({
4761
4944
  if (ts.isCallExpression(node)) {
4762
4945
  yield* pipe(
4763
4946
  typeParser.unnecessaryEffectGen(node),
4764
- map3(
4947
+ map4(
4765
4948
  ({ replacementNode }) => report({
4766
4949
  location: node,
4767
4950
  messageText: `This Effect.gen contains a single return statement.`,
@@ -4804,7 +4987,7 @@ var unnecessaryPipe = createDiagnostic({
4804
4987
  if (ts.isCallExpression(node)) {
4805
4988
  yield* pipe(
4806
4989
  typeParser.pipeCall(node),
4807
- map3(({ args: args2, subject }) => {
4990
+ map4(({ args: args2, subject }) => {
4808
4991
  if (args2.length === 0) {
4809
4992
  report({
4810
4993
  location: node,
@@ -4850,9 +5033,9 @@ var unnecessaryPipeChain = createDiagnostic({
4850
5033
  yield* pipe(
4851
5034
  typeParser.pipeCall(node),
4852
5035
  flatMap2(
4853
- (pipeCall) => map3(typeParser.pipeCall(pipeCall.subject), (innerCall) => ({ pipeCall, innerCall }))
5036
+ (pipeCall) => map4(typeParser.pipeCall(pipeCall.subject), (innerCall) => ({ pipeCall, innerCall }))
4854
5037
  ),
4855
- map3(({ innerCall, pipeCall }) => {
5038
+ map4(({ innerCall, pipeCall }) => {
4856
5039
  report({
4857
5040
  location: node,
4858
5041
  messageText: `Chained pipe calls can be simplified to a single pipe call`,
@@ -4929,15 +5112,15 @@ var unsupportedServiceAccessors = createDiagnostic({
4929
5112
  node.members?.forEach((member) => {
4930
5113
  if (ts.isPropertyDeclaration(member) && member.modifiers?.some((mod) => mod.kind === ts.SyntaxKind.StaticKeyword)) {
4931
5114
  if (member.name && ts.isIdentifier(member.name)) {
4932
- existingStaticMembers.add(member.name.text);
5115
+ existingStaticMembers.add(ts.idText(member.name));
4933
5116
  }
4934
5117
  }
4935
5118
  });
4936
5119
  const missingMembers = parseResult.involvedMembers.filter(
4937
- ({ property }) => !existingStaticMembers.has(property.getName())
5120
+ ({ property }) => !existingStaticMembers.has(ts.symbolName(property))
4938
5121
  );
4939
5122
  if (missingMembers.length > 0) {
4940
- const memberNames = missingMembers.map(({ property }) => `'${property.getName()}'`).join(", ");
5123
+ const memberNames = missingMembers.map(({ property }) => `'${ts.symbolName(property)}'`).join(", ");
4941
5124
  report({
4942
5125
  location: parseResult.className,
4943
5126
  messageText: `Even if accessors are enabled, accessors for ${memberNames} won't be available because the signature have generic type parameters or multiple call signatures.`,
@@ -4947,7 +5130,7 @@ var unsupportedServiceAccessors = createDiagnostic({
4947
5130
  apply: gen(function* () {
4948
5131
  const changeTracker = yield* service(ChangeTracker);
4949
5132
  const comment = "// @effect-codegens accessors\n";
4950
- changeTracker.insertText(sourceFile, node.getStart(sourceFile), comment);
5133
+ changeTracker.insertText(sourceFile, ts.getTokenPosOfNode(node, sourceFile), comment);
4951
5134
  })
4952
5135
  }]
4953
5136
  });
@@ -4991,6 +5174,7 @@ function transform_default(program, pluginConfig, { addDiagnostic, ts: tsInstanc
4991
5174
  return (sourceFile) => {
4992
5175
  pipe(
4993
5176
  getSemanticDiagnosticsWithCodeFixes(diagnostics, sourceFile),
5177
+ nanoLayer3,
4994
5178
  nanoLayer2,
4995
5179
  nanoLayer,
4996
5180
  provideService(TypeCheckerApi, program.getTypeChecker()),
@@ -5008,7 +5192,7 @@ function transform_default(program, pluginConfig, { addDiagnostic, ts: tsInstanc
5008
5192
  )
5009
5193
  ),
5010
5194
  getOrElse(() => []),
5011
- map2(addDiagnostic)
5195
+ map3(addDiagnostic)
5012
5196
  );
5013
5197
  return sourceFile;
5014
5198
  };