@effect/language-service 0.62.4 → 0.63.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/README.md +5 -1
- package/cli.js +2756 -676
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +345 -148
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +462 -204
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +345 -148
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
// node_modules/.pnpm/effect@3.19.
|
|
3
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Function.js
|
|
4
4
|
var isFunction = (input) => typeof input === "function";
|
|
5
5
|
var dual = function(arity, body) {
|
|
6
6
|
if (typeof arity === "function") {
|
|
@@ -98,7 +98,7 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
// node_modules/.pnpm/effect@3.19.
|
|
101
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Equivalence.js
|
|
102
102
|
var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
|
|
103
103
|
var array = (item) => make((self, that) => {
|
|
104
104
|
if (self.length !== that.length) {
|
|
@@ -113,7 +113,7 @@ var array = (item) => make((self, that) => {
|
|
|
113
113
|
return true;
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
// node_modules/.pnpm/effect@3.19.
|
|
116
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/GlobalValue.js
|
|
117
117
|
var globalStoreId = `effect/GlobalValue`;
|
|
118
118
|
var globalStore;
|
|
119
119
|
var globalValue = (id, compute) => {
|
|
@@ -127,7 +127,7 @@ var globalValue = (id, compute) => {
|
|
|
127
127
|
return globalStore.get(id);
|
|
128
128
|
};
|
|
129
129
|
|
|
130
|
-
// node_modules/.pnpm/effect@3.19.
|
|
130
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Predicate.js
|
|
131
131
|
var isString = (input) => typeof input === "string";
|
|
132
132
|
var isNumber = (input) => typeof input === "number";
|
|
133
133
|
var isBoolean = (input) => typeof input === "boolean";
|
|
@@ -138,10 +138,10 @@ var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) &&
|
|
|
138
138
|
var isTagged = /* @__PURE__ */ dual(2, (self, tag) => hasProperty(self, "_tag") && self["_tag"] === tag);
|
|
139
139
|
var isRecord = (input) => isRecordOrArray(input) && !Array.isArray(input);
|
|
140
140
|
|
|
141
|
-
// node_modules/.pnpm/effect@3.19.
|
|
141
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/errors.js
|
|
142
142
|
var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
|
|
143
143
|
|
|
144
|
-
// node_modules/.pnpm/effect@3.19.
|
|
144
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Utils.js
|
|
145
145
|
var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
|
|
146
146
|
var GenKindImpl = class {
|
|
147
147
|
value;
|
|
@@ -263,7 +263,7 @@ var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forc
|
|
|
263
263
|
var genConstructor = function* () {
|
|
264
264
|
}.constructor;
|
|
265
265
|
|
|
266
|
-
// node_modules/.pnpm/effect@3.19.
|
|
266
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Hash.js
|
|
267
267
|
var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
|
|
268
268
|
var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
|
|
269
269
|
var hash = (self) => {
|
|
@@ -288,6 +288,9 @@ var hash = (self) => {
|
|
|
288
288
|
if (self === null) {
|
|
289
289
|
return string("null");
|
|
290
290
|
} else if (self instanceof Date) {
|
|
291
|
+
if (Number.isNaN(self.getTime())) {
|
|
292
|
+
return string("Invalid Date");
|
|
293
|
+
}
|
|
291
294
|
return hash(self.toISOString());
|
|
292
295
|
} else if (self instanceof URL) {
|
|
293
296
|
return hash(self.href);
|
|
@@ -369,7 +372,7 @@ var cached = function() {
|
|
|
369
372
|
return hash2;
|
|
370
373
|
};
|
|
371
374
|
|
|
372
|
-
// node_modules/.pnpm/effect@3.19.
|
|
375
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Equal.js
|
|
373
376
|
var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
|
|
374
377
|
function equals() {
|
|
375
378
|
if (arguments.length === 1) {
|
|
@@ -394,7 +397,9 @@ function compareBoth(self, that) {
|
|
|
394
397
|
return structuralRegionState.enabled && structuralRegionState.tester ? structuralRegionState.tester(self, that) : false;
|
|
395
398
|
}
|
|
396
399
|
} else if (self instanceof Date && that instanceof Date) {
|
|
397
|
-
|
|
400
|
+
const t1 = self.getTime();
|
|
401
|
+
const t2 = that.getTime();
|
|
402
|
+
return t1 === t2 || Number.isNaN(t1) && Number.isNaN(t2);
|
|
398
403
|
} else if (self instanceof URL && that instanceof URL) {
|
|
399
404
|
return self.href === that.href;
|
|
400
405
|
}
|
|
@@ -423,7 +428,7 @@ function compareBoth(self, that) {
|
|
|
423
428
|
var isEqual = (u) => hasProperty(u, symbol2);
|
|
424
429
|
var equivalence = () => equals;
|
|
425
430
|
|
|
426
|
-
// node_modules/.pnpm/effect@3.19.
|
|
431
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Inspectable.js
|
|
427
432
|
var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
428
433
|
var toJSON = (x) => {
|
|
429
434
|
try {
|
|
@@ -481,7 +486,7 @@ var redact = (u) => {
|
|
|
481
486
|
return u;
|
|
482
487
|
};
|
|
483
488
|
|
|
484
|
-
// node_modules/.pnpm/effect@3.19.
|
|
489
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Pipeable.js
|
|
485
490
|
var pipeArguments = (self, args2) => {
|
|
486
491
|
switch (args2.length) {
|
|
487
492
|
case 0:
|
|
@@ -514,16 +519,16 @@ var pipeArguments = (self, args2) => {
|
|
|
514
519
|
}
|
|
515
520
|
};
|
|
516
521
|
|
|
517
|
-
// node_modules/.pnpm/effect@3.19.
|
|
522
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/opCodes/effect.js
|
|
518
523
|
var OP_COMMIT = "Commit";
|
|
519
524
|
var OP_FAILURE = "Failure";
|
|
520
525
|
var OP_WITH_RUNTIME = "WithRuntime";
|
|
521
526
|
|
|
522
|
-
// node_modules/.pnpm/effect@3.19.
|
|
523
|
-
var moduleVersion = "3.19.
|
|
527
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/version.js
|
|
528
|
+
var moduleVersion = "3.19.13";
|
|
524
529
|
var getCurrentVersion = () => moduleVersion;
|
|
525
530
|
|
|
526
|
-
// node_modules/.pnpm/effect@3.19.
|
|
531
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/effectable.js
|
|
527
532
|
var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
|
|
528
533
|
var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
|
|
529
534
|
var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
|
|
@@ -610,7 +615,7 @@ var StructuralCommitPrototype = {
|
|
|
610
615
|
...StructuralPrototype
|
|
611
616
|
};
|
|
612
617
|
|
|
613
|
-
// node_modules/.pnpm/effect@3.19.
|
|
618
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/option.js
|
|
614
619
|
var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
|
|
615
620
|
var CommonProto = {
|
|
616
621
|
...EffectPrototype,
|
|
@@ -668,7 +673,7 @@ var some = (value) => {
|
|
|
668
673
|
return a;
|
|
669
674
|
};
|
|
670
675
|
|
|
671
|
-
// node_modules/.pnpm/effect@3.19.
|
|
676
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/either.js
|
|
672
677
|
var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
|
|
673
678
|
var CommonProto2 = {
|
|
674
679
|
...EffectPrototype,
|
|
@@ -730,7 +735,7 @@ var right = (right3) => {
|
|
|
730
735
|
return a;
|
|
731
736
|
};
|
|
732
737
|
|
|
733
|
-
// node_modules/.pnpm/effect@3.19.
|
|
738
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Either.js
|
|
734
739
|
var right2 = right;
|
|
735
740
|
var left2 = left;
|
|
736
741
|
var isLeft2 = isLeft;
|
|
@@ -738,17 +743,17 @@ var isRight2 = isRight;
|
|
|
738
743
|
var map = /* @__PURE__ */ dual(2, (self, f) => isRight2(self) ? right2(f(self.right)) : left2(self.left));
|
|
739
744
|
var getOrElse = /* @__PURE__ */ dual(2, (self, onLeft) => isLeft2(self) ? onLeft(self.left) : self.right);
|
|
740
745
|
|
|
741
|
-
// node_modules/.pnpm/effect@3.19.
|
|
746
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/array.js
|
|
742
747
|
var isNonEmptyArray = (self) => self.length > 0;
|
|
743
748
|
|
|
744
|
-
// node_modules/.pnpm/effect@3.19.
|
|
749
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Order.js
|
|
745
750
|
var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that);
|
|
746
751
|
var string2 = /* @__PURE__ */ make2((self, that) => self < that ? -1 : 1);
|
|
747
752
|
var number2 = /* @__PURE__ */ make2((self, that) => self < that ? -1 : 1);
|
|
748
753
|
var reverse = (O) => make2((self, that) => O(that, self));
|
|
749
754
|
var mapInput = /* @__PURE__ */ dual(2, (self, f) => make2((b1, b2) => self(f(b1), f(b2))));
|
|
750
755
|
|
|
751
|
-
// node_modules/.pnpm/effect@3.19.
|
|
756
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Option.js
|
|
752
757
|
var none2 = () => none;
|
|
753
758
|
var some2 = some;
|
|
754
759
|
var isNone2 = isNone;
|
|
@@ -759,7 +764,7 @@ var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nu
|
|
|
759
764
|
var getOrUndefined = /* @__PURE__ */ getOrElse2(constUndefined);
|
|
760
765
|
var map2 = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
|
|
761
766
|
|
|
762
|
-
// node_modules/.pnpm/effect@3.19.
|
|
767
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Record.js
|
|
763
768
|
var map3 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
764
769
|
const out = {
|
|
765
770
|
...self
|
|
@@ -771,7 +776,7 @@ var map3 = /* @__PURE__ */ dual(2, (self, f) => {
|
|
|
771
776
|
});
|
|
772
777
|
var keys = (self) => Object.keys(self);
|
|
773
778
|
|
|
774
|
-
// node_modules/.pnpm/effect@3.19.
|
|
779
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Array.js
|
|
775
780
|
var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
|
|
776
781
|
var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
|
|
777
782
|
var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
|
|
@@ -811,7 +816,10 @@ var containsWith = (isEquivalent) => dual(2, (self, a) => {
|
|
|
811
816
|
var _equivalence = /* @__PURE__ */ equivalence();
|
|
812
817
|
var intersectionWith = (isEquivalent) => {
|
|
813
818
|
const has3 = containsWith(isEquivalent);
|
|
814
|
-
return dual(2, (self, that) =>
|
|
819
|
+
return dual(2, (self, that) => {
|
|
820
|
+
const bs = fromIterable(that);
|
|
821
|
+
return fromIterable(self).filter((a) => has3(bs, a));
|
|
822
|
+
});
|
|
815
823
|
};
|
|
816
824
|
var intersection = /* @__PURE__ */ intersectionWith(_equivalence);
|
|
817
825
|
var empty = () => [];
|
|
@@ -872,7 +880,7 @@ var dedupeWith = /* @__PURE__ */ dual(2, (self, isEquivalent) => {
|
|
|
872
880
|
var dedupe = (self) => dedupeWith(self, equivalence());
|
|
873
881
|
var join = /* @__PURE__ */ dual(2, (self, sep) => fromIterable(self).join(sep));
|
|
874
882
|
|
|
875
|
-
// node_modules/.pnpm/effect@3.19.
|
|
883
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Chunk.js
|
|
876
884
|
var TypeId3 = /* @__PURE__ */ Symbol.for("effect/Chunk");
|
|
877
885
|
function copy(src, srcPos, dest, destPos, len) {
|
|
878
886
|
for (let i = srcPos; i < Math.min(src.length, srcPos + len); i++) {
|
|
@@ -1168,14 +1176,14 @@ var isNonEmpty = (self) => self.length > 0;
|
|
|
1168
1176
|
var unsafeHead = (self) => unsafeGet2(self, 0);
|
|
1169
1177
|
var headNonEmpty2 = unsafeHead;
|
|
1170
1178
|
|
|
1171
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1179
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/config.js
|
|
1172
1180
|
var SIZE = 5;
|
|
1173
1181
|
var BUCKET_SIZE = /* @__PURE__ */ Math.pow(2, SIZE);
|
|
1174
1182
|
var MASK = BUCKET_SIZE - 1;
|
|
1175
1183
|
var MAX_INDEX_NODE = BUCKET_SIZE / 2;
|
|
1176
1184
|
var MIN_ARRAY_NODE = BUCKET_SIZE / 4;
|
|
1177
1185
|
|
|
1178
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1186
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/bitwise.js
|
|
1179
1187
|
function popcount(x) {
|
|
1180
1188
|
x -= x >> 1 & 1431655765;
|
|
1181
1189
|
x = (x & 858993459) + (x >> 2 & 858993459);
|
|
@@ -1194,13 +1202,13 @@ function fromBitmap(bitmap, bit) {
|
|
|
1194
1202
|
return popcount(bitmap & bit - 1);
|
|
1195
1203
|
}
|
|
1196
1204
|
|
|
1197
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1205
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/stack.js
|
|
1198
1206
|
var make4 = (value, previous) => ({
|
|
1199
1207
|
value,
|
|
1200
1208
|
previous
|
|
1201
1209
|
});
|
|
1202
1210
|
|
|
1203
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1211
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/array.js
|
|
1204
1212
|
function arrayUpdate(mutate3, at, v, arr) {
|
|
1205
1213
|
let out = arr;
|
|
1206
1214
|
if (!mutate3) {
|
|
@@ -1245,7 +1253,7 @@ function arraySpliceIn(mutate3, at, v, arr) {
|
|
|
1245
1253
|
return out;
|
|
1246
1254
|
}
|
|
1247
1255
|
|
|
1248
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1256
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap/node.js
|
|
1249
1257
|
var EmptyNode = class _EmptyNode {
|
|
1250
1258
|
_tag = "EmptyNode";
|
|
1251
1259
|
modify(edit, _shift, f, hash2, key, size4) {
|
|
@@ -1480,7 +1488,7 @@ function mergeLeaves(edit, shift, h1, n1, h2, n2) {
|
|
|
1480
1488
|
}
|
|
1481
1489
|
}
|
|
1482
1490
|
|
|
1483
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1491
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashMap.js
|
|
1484
1492
|
var HashMapSymbolKey = "effect/HashMap";
|
|
1485
1493
|
var HashMapTypeId = /* @__PURE__ */ Symbol.for(HashMapSymbolKey);
|
|
1486
1494
|
var HashMapProto = {
|
|
@@ -1692,7 +1700,7 @@ var reduce2 = /* @__PURE__ */ dual(3, (self, zero2, f) => {
|
|
|
1692
1700
|
return zero2;
|
|
1693
1701
|
});
|
|
1694
1702
|
|
|
1695
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1703
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/hashSet.js
|
|
1696
1704
|
var HashSetSymbolKey = "effect/HashSet";
|
|
1697
1705
|
var HashSetTypeId = /* @__PURE__ */ Symbol.for(HashSetSymbolKey);
|
|
1698
1706
|
var HashSetProto = {
|
|
@@ -1754,13 +1762,13 @@ var union2 = /* @__PURE__ */ dual(2, (self, that) => mutate(empty4(), (set2) =>
|
|
|
1754
1762
|
}));
|
|
1755
1763
|
var forEach2 = /* @__PURE__ */ dual(2, (self, f) => forEach(self._keyMap, (_, k) => f(k)));
|
|
1756
1764
|
|
|
1757
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1765
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/HashSet.js
|
|
1758
1766
|
var empty5 = empty4;
|
|
1759
1767
|
var size3 = size2;
|
|
1760
1768
|
var add2 = add;
|
|
1761
1769
|
var union3 = union2;
|
|
1762
1770
|
|
|
1763
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1771
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/data.js
|
|
1764
1772
|
var ArrayProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(Array.prototype), {
|
|
1765
1773
|
[symbol]() {
|
|
1766
1774
|
return cached(this, array2(this));
|
|
@@ -1783,7 +1791,7 @@ var Structural = /* @__PURE__ */ (function() {
|
|
|
1783
1791
|
return Structural2;
|
|
1784
1792
|
})();
|
|
1785
1793
|
|
|
1786
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1794
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/opCodes/cause.js
|
|
1787
1795
|
var OP_DIE = "Die";
|
|
1788
1796
|
var OP_EMPTY = "Empty";
|
|
1789
1797
|
var OP_FAIL = "Fail";
|
|
@@ -1791,7 +1799,7 @@ var OP_INTERRUPT = "Interrupt";
|
|
|
1791
1799
|
var OP_PARALLEL = "Parallel";
|
|
1792
1800
|
var OP_SEQUENTIAL = "Sequential";
|
|
1793
1801
|
|
|
1794
|
-
// node_modules/.pnpm/effect@3.19.
|
|
1802
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/cause.js
|
|
1795
1803
|
var CauseSymbolKey = "effect/Cause";
|
|
1796
1804
|
var CauseTypeId = /* @__PURE__ */ Symbol.for(CauseSymbolKey);
|
|
1797
1805
|
var variance = {
|
|
@@ -2223,7 +2231,7 @@ var prettyErrors = (cause) => reduceWithContext(cause, void 0, {
|
|
|
2223
2231
|
sequentialCase: (_, l, r) => [...l, ...r]
|
|
2224
2232
|
});
|
|
2225
2233
|
|
|
2226
|
-
// node_modules/.pnpm/effect@3.19.
|
|
2234
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/singleShotGen.js
|
|
2227
2235
|
var SingleShotGen2 = class _SingleShotGen {
|
|
2228
2236
|
self;
|
|
2229
2237
|
called = false;
|
|
@@ -2253,7 +2261,7 @@ var SingleShotGen2 = class _SingleShotGen {
|
|
|
2253
2261
|
}
|
|
2254
2262
|
};
|
|
2255
2263
|
|
|
2256
|
-
// node_modules/.pnpm/effect@3.19.
|
|
2264
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/core.js
|
|
2257
2265
|
var EffectTypeId2 = /* @__PURE__ */ Symbol.for("effect/Effect");
|
|
2258
2266
|
var EffectPrimitive = class {
|
|
2259
2267
|
_op;
|
|
@@ -2537,7 +2545,7 @@ var currentSpanFromFiber = (fiber) => {
|
|
|
2537
2545
|
return span !== void 0 && span._tag === "Span" ? some2(span) : none2();
|
|
2538
2546
|
};
|
|
2539
2547
|
|
|
2540
|
-
// node_modules/.pnpm/effect@3.19.
|
|
2548
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Data.js
|
|
2541
2549
|
var Class2 = Structural;
|
|
2542
2550
|
var Error2 = /* @__PURE__ */ (function() {
|
|
2543
2551
|
const plainArgsSymbol = /* @__PURE__ */ Symbol.for("effect/Data/Error/plainArgs");
|
|
@@ -2575,10 +2583,10 @@ var TaggedError = (tag) => {
|
|
|
2575
2583
|
return O.BaseEffectError;
|
|
2576
2584
|
};
|
|
2577
2585
|
|
|
2578
|
-
// node_modules/.pnpm/effect@3.19.
|
|
2586
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/encoding/common.js
|
|
2579
2587
|
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
2580
2588
|
|
|
2581
|
-
// node_modules/.pnpm/effect@3.19.
|
|
2589
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/encoding/base64.js
|
|
2582
2590
|
var encode = (bytes) => {
|
|
2583
2591
|
const length = bytes.length;
|
|
2584
2592
|
let result = "";
|
|
@@ -2604,13 +2612,13 @@ var encode = (bytes) => {
|
|
|
2604
2612
|
};
|
|
2605
2613
|
var base64abc = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "/"];
|
|
2606
2614
|
|
|
2607
|
-
// node_modules/.pnpm/effect@3.19.
|
|
2615
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/internal/encoding/base64Url.js
|
|
2608
2616
|
var encode2 = (data) => encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
2609
2617
|
|
|
2610
|
-
// node_modules/.pnpm/effect@3.19.
|
|
2618
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Encoding.js
|
|
2611
2619
|
var encodeBase64Url = (input) => typeof input === "string" ? encode2(encoder.encode(input)) : encode2(input);
|
|
2612
2620
|
|
|
2613
|
-
// node_modules/.pnpm/effect@3.19.
|
|
2621
|
+
// node_modules/.pnpm/effect@3.19.13/node_modules/effect/dist/esm/Graph.js
|
|
2614
2622
|
var TypeId4 = "~effect/Graph";
|
|
2615
2623
|
var Edge = class extends Class2 {
|
|
2616
2624
|
};
|
|
@@ -3118,12 +3126,12 @@ var SingleShotGen3 = class _SingleShotGen {
|
|
|
3118
3126
|
return new _SingleShotGen(this.self);
|
|
3119
3127
|
}
|
|
3120
3128
|
};
|
|
3121
|
-
var evaluate = Symbol.for("Nano.evaluate");
|
|
3122
|
-
var contA = Symbol.for("Nano.contA");
|
|
3123
|
-
var contE = Symbol.for("Nano.contE");
|
|
3124
|
-
var contAll = Symbol.for("Nano.contAll");
|
|
3125
|
-
var NanoYield = Symbol.for("Nano.yield");
|
|
3126
|
-
var args = Symbol.for("Nano.args");
|
|
3129
|
+
var evaluate = /* @__PURE__ */ Symbol.for("Nano.evaluate");
|
|
3130
|
+
var contA = /* @__PURE__ */ Symbol.for("Nano.contA");
|
|
3131
|
+
var contE = /* @__PURE__ */ Symbol.for("Nano.contE");
|
|
3132
|
+
var contAll = /* @__PURE__ */ Symbol.for("Nano.contAll");
|
|
3133
|
+
var NanoYield = /* @__PURE__ */ Symbol.for("Nano.yield");
|
|
3134
|
+
var args = /* @__PURE__ */ Symbol.for("Nano.args");
|
|
3127
3135
|
var NanoDefectException = class {
|
|
3128
3136
|
constructor(message, lastSpan) {
|
|
3129
3137
|
this.message = message;
|
|
@@ -3945,7 +3953,9 @@ function makeTypeScriptUtils(ts) {
|
|
|
3945
3953
|
} else {
|
|
3946
3954
|
return;
|
|
3947
3955
|
}
|
|
3948
|
-
|
|
3956
|
+
const importDeclaration = ts.findAncestor(accessedObject, ts.isImportDeclaration);
|
|
3957
|
+
if (importDeclaration) return;
|
|
3958
|
+
return { accessedObject, outerNode, replacementSpan, insideImportDeclaration: !!importDeclaration };
|
|
3949
3959
|
}
|
|
3950
3960
|
function parseDataForExtendsClassCompletion(sourceFile, position) {
|
|
3951
3961
|
const maybeInfos = parseAccessedExpressionForCompletion(sourceFile, position);
|
|
@@ -4525,6 +4535,8 @@ var nanoLayer2 = (fa) => pipe(
|
|
|
4525
4535
|
function makeTypeCheckerUtils(ts, typeChecker, tsUtils) {
|
|
4526
4536
|
const readonlyArraySymbol = typeChecker.resolveName("ReadonlyArray", void 0, ts.SymbolFlags.Type, false);
|
|
4527
4537
|
const globalReadonlyArrayType = readonlyArraySymbol ? typeChecker.getDeclaredTypeOfSymbol(readonlyArraySymbol) : void 0;
|
|
4538
|
+
const errorSymbol = typeChecker.resolveName("Error", void 0, ts.SymbolFlags.Type, false);
|
|
4539
|
+
const globalErrorType = errorSymbol ? typeChecker.getDeclaredTypeOfSymbol(errorSymbol) : void 0;
|
|
4528
4540
|
function isUnion(type) {
|
|
4529
4541
|
return !!(type.flags & ts.TypeFlags.Union);
|
|
4530
4542
|
}
|
|
@@ -4773,6 +4785,10 @@ function makeTypeCheckerUtils(ts, typeChecker, tsUtils) {
|
|
|
4773
4785
|
function typeToSimplifiedTypeNode(type, enclosingNode, flags) {
|
|
4774
4786
|
return typeToSimplifiedTypeNodeWorker(type, enclosingNode, flags, 0);
|
|
4775
4787
|
}
|
|
4788
|
+
function isGlobalErrorType(type) {
|
|
4789
|
+
if (!globalErrorType) return false;
|
|
4790
|
+
return typeChecker.isTypeAssignableTo(type, globalErrorType) && typeChecker.isTypeAssignableTo(globalErrorType, type);
|
|
4791
|
+
}
|
|
4776
4792
|
function typeToSimplifiedTypeNodeWorker(type, enclosingNode, flags, depth) {
|
|
4777
4793
|
const fallbackStandard = () => {
|
|
4778
4794
|
const typeNode = typeChecker.typeToTypeNode(type, enclosingNode, flags);
|
|
@@ -4842,6 +4858,15 @@ function makeTypeCheckerUtils(ts, typeChecker, tsUtils) {
|
|
|
4842
4858
|
}
|
|
4843
4859
|
return fallbackStandard();
|
|
4844
4860
|
}
|
|
4861
|
+
function getTypeAtLocation(node) {
|
|
4862
|
+
if (node.parent && ts.isJsxSelfClosingElement(node.parent) && node.parent.tagName === node) return;
|
|
4863
|
+
if (node.parent && ts.isJsxOpeningElement(node.parent) && node.parent.tagName === node) return;
|
|
4864
|
+
if (node.parent && ts.isJsxClosingElement(node.parent) && node.parent.tagName === node) return;
|
|
4865
|
+
if (node.parent && ts.isJsxAttribute(node.parent) && node.parent.name === node) return;
|
|
4866
|
+
if (ts.isExpression(node) || ts.isTypeNode(node)) {
|
|
4867
|
+
return typeChecker.getTypeAtLocation(node);
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4845
4870
|
return {
|
|
4846
4871
|
isUnion,
|
|
4847
4872
|
isReadonlyArrayType,
|
|
@@ -4853,7 +4878,9 @@ function makeTypeCheckerUtils(ts, typeChecker, tsUtils) {
|
|
|
4853
4878
|
deterministicTypeOrder,
|
|
4854
4879
|
getInferredReturnType,
|
|
4855
4880
|
expectedAndRealType,
|
|
4856
|
-
typeToSimplifiedTypeNode
|
|
4881
|
+
typeToSimplifiedTypeNode,
|
|
4882
|
+
isGlobalErrorType,
|
|
4883
|
+
getTypeAtLocation
|
|
4857
4884
|
};
|
|
4858
4885
|
}
|
|
4859
4886
|
|
|
@@ -4975,7 +5002,7 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
4975
5002
|
return isSymbolExportOfPackageModule(symbol3, packageName, memberName, isCorrectSourceFile);
|
|
4976
5003
|
};
|
|
4977
5004
|
const findSymbolsMatchingPackageAndExportedName = (packageName, exportedSymbolName) => cachedBy(
|
|
4978
|
-
fn("TypeParser.findSymbolsMatchingPackageAndExportedName")(function* (
|
|
5005
|
+
fn("TypeParser.findSymbolsMatchingPackageAndExportedName")(function* () {
|
|
4979
5006
|
const result = [];
|
|
4980
5007
|
for (const sourceFile of program.getSourceFiles()) {
|
|
4981
5008
|
const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
|
|
@@ -4989,7 +5016,7 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
4989
5016
|
return result;
|
|
4990
5017
|
}),
|
|
4991
5018
|
`TypeParser.findSymbolsMatchingPackageAndExportedName(${packageName}, ${exportedSymbolName})`,
|
|
4992
|
-
(
|
|
5019
|
+
() => program
|
|
4993
5020
|
);
|
|
4994
5021
|
const isCauseTypeSourceFile = cachedBy(
|
|
4995
5022
|
fn("TypeParser.isCauseTypeSourceFile")(function* (sourceFile) {
|
|
@@ -5004,20 +5031,22 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
5004
5031
|
"TypeParser.isCauseTypeSourceFile",
|
|
5005
5032
|
(sourceFile) => sourceFile
|
|
5006
5033
|
);
|
|
5007
|
-
const
|
|
5008
|
-
fn("TypeParser.
|
|
5009
|
-
const symbols = yield* findSymbolsMatchingPackageAndExportedName("effect", "YieldableError")(
|
|
5010
|
-
const result = [];
|
|
5034
|
+
const extendsCauseYieldableError = cachedBy(
|
|
5035
|
+
fn("TypeParser.extendsCauseYieldableError")(function* (givenType) {
|
|
5036
|
+
const symbols = yield* findSymbolsMatchingPackageAndExportedName("effect", "YieldableError")();
|
|
5011
5037
|
for (const [symbol3, sourceFile] of symbols) {
|
|
5012
|
-
const causeFile = yield* isCauseTypeSourceFile(sourceFile);
|
|
5038
|
+
const causeFile = yield* pipe(isCauseTypeSourceFile(sourceFile), orElse2(() => void_));
|
|
5013
5039
|
if (!causeFile) continue;
|
|
5014
5040
|
const type = typeChecker.getDeclaredTypeOfSymbol(symbol3);
|
|
5015
|
-
|
|
5041
|
+
if (!type) continue;
|
|
5042
|
+
if (typeChecker.isTypeAssignableTo(givenType, type)) {
|
|
5043
|
+
return type;
|
|
5044
|
+
}
|
|
5016
5045
|
}
|
|
5017
|
-
return
|
|
5046
|
+
return yield* typeParserIssue("Type does not extend Cause.YieldableError", givenType);
|
|
5018
5047
|
}),
|
|
5019
|
-
"TypeParser.
|
|
5020
|
-
(
|
|
5048
|
+
"TypeParser.extendsCauseYieldableError",
|
|
5049
|
+
(type) => type
|
|
5021
5050
|
);
|
|
5022
5051
|
function covariantTypeArgument(type) {
|
|
5023
5052
|
const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
@@ -5407,7 +5436,8 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
5407
5436
|
}
|
|
5408
5437
|
if (ts.isYieldExpression(nodeToCheck) && nodeToCheck.asteriskToken && nodeToCheck.expression) {
|
|
5409
5438
|
const yieldedExpression = nodeToCheck.expression;
|
|
5410
|
-
const type =
|
|
5439
|
+
const type = typeCheckerUtils.getTypeAtLocation(yieldedExpression);
|
|
5440
|
+
if (!type) continue;
|
|
5411
5441
|
const { A: successType } = yield* effectType(type, yieldedExpression);
|
|
5412
5442
|
let replacementNode = succeed(yieldedExpression);
|
|
5413
5443
|
if (!explicitReturn && !(successType.flags & ts.TypeFlags.VoidLike)) {
|
|
@@ -5998,11 +6028,79 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
5998
6028
|
"TypeParser.extendsEffectService",
|
|
5999
6029
|
(atLocation) => atLocation
|
|
6000
6030
|
);
|
|
6031
|
+
const isEffectSqlModelTypeSourceFile = cachedBy(
|
|
6032
|
+
fn("TypeParser.isEffectSqlModelTypeSourceFile")(function* (sourceFile) {
|
|
6033
|
+
const moduleSymbol = typeChecker.getSymbolAtLocation(sourceFile);
|
|
6034
|
+
if (!moduleSymbol) return yield* typeParserIssue("Node has no symbol", void 0, sourceFile);
|
|
6035
|
+
const classSymbol = typeChecker.tryGetMemberInModuleExports("Class", moduleSymbol);
|
|
6036
|
+
if (!classSymbol) return yield* typeParserIssue("Model's Class type not found", void 0, sourceFile);
|
|
6037
|
+
const makeRepositorySymbol = typeChecker.tryGetMemberInModuleExports("makeRepository", moduleSymbol);
|
|
6038
|
+
if (!makeRepositorySymbol) {
|
|
6039
|
+
return yield* typeParserIssue("Model's makeRepository type not found", void 0, sourceFile);
|
|
6040
|
+
}
|
|
6041
|
+
const makeDataLoadersSymbol = typeChecker.tryGetMemberInModuleExports("makeDataLoaders", moduleSymbol);
|
|
6042
|
+
if (!makeDataLoadersSymbol) {
|
|
6043
|
+
return yield* typeParserIssue("Model's makeDataLoaders type not found", void 0, sourceFile);
|
|
6044
|
+
}
|
|
6045
|
+
return sourceFile;
|
|
6046
|
+
}),
|
|
6047
|
+
"TypeParser.isEffectSqlModelTypeSourceFile",
|
|
6048
|
+
(sourceFile) => sourceFile
|
|
6049
|
+
);
|
|
6050
|
+
const isNodeReferenceToEffectSqlModelModuleApi = (memberName) => cachedBy(
|
|
6051
|
+
fn("TypeParser.isNodeReferenceToEffectSqlModelModuleApi")(function* (node) {
|
|
6052
|
+
return yield* isNodeReferenceToExportOfPackageModule(
|
|
6053
|
+
node,
|
|
6054
|
+
"@effect/sql",
|
|
6055
|
+
isEffectSqlModelTypeSourceFile,
|
|
6056
|
+
memberName
|
|
6057
|
+
);
|
|
6058
|
+
}),
|
|
6059
|
+
`TypeParser.isNodeReferenceToEffectSqlModelModuleApi(${memberName})`,
|
|
6060
|
+
(node) => node
|
|
6061
|
+
);
|
|
6062
|
+
const extendsEffectSqlModelClass = cachedBy(
|
|
6063
|
+
fn("TypeParser.extendsEffectSqlModelClass")(function* (atLocation) {
|
|
6064
|
+
if (!atLocation.name) {
|
|
6065
|
+
return yield* typeParserIssue("Class has no name", void 0, atLocation);
|
|
6066
|
+
}
|
|
6067
|
+
const heritageClauses = atLocation.heritageClauses;
|
|
6068
|
+
if (!heritageClauses) {
|
|
6069
|
+
return yield* typeParserIssue("Class has no heritage clauses", void 0, atLocation);
|
|
6070
|
+
}
|
|
6071
|
+
for (const heritageClause of heritageClauses) {
|
|
6072
|
+
for (const typeX of heritageClause.types) {
|
|
6073
|
+
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
6074
|
+
const expression = typeX.expression;
|
|
6075
|
+
if (ts.isCallExpression(expression)) {
|
|
6076
|
+
const schemaCall = expression.expression;
|
|
6077
|
+
if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
|
|
6078
|
+
const isEffectSchemaModuleApi = yield* pipe(
|
|
6079
|
+
isNodeReferenceToEffectSqlModelModuleApi("Class")(schemaCall.expression),
|
|
6080
|
+
option
|
|
6081
|
+
);
|
|
6082
|
+
if (isSome2(isEffectSchemaModuleApi)) {
|
|
6083
|
+
return {
|
|
6084
|
+
className: atLocation.name,
|
|
6085
|
+
selfTypeNode: schemaCall.typeArguments[0]
|
|
6086
|
+
};
|
|
6087
|
+
}
|
|
6088
|
+
}
|
|
6089
|
+
}
|
|
6090
|
+
}
|
|
6091
|
+
}
|
|
6092
|
+
}
|
|
6093
|
+
return yield* typeParserIssue("Class does not extend @effect/sql's Model.Class", void 0, atLocation);
|
|
6094
|
+
}),
|
|
6095
|
+
"TypeParser.extendsEffectSqlModelClass",
|
|
6096
|
+
(atLocation) => atLocation
|
|
6097
|
+
);
|
|
6001
6098
|
return {
|
|
6002
6099
|
isNodeReferenceToEffectModuleApi,
|
|
6003
6100
|
isNodeReferenceToEffectSchemaModuleApi,
|
|
6004
6101
|
isNodeReferenceToEffectDataModuleApi,
|
|
6005
6102
|
isNodeReferenceToEffectContextModuleApi,
|
|
6103
|
+
isNodeReferenceToEffectSqlModelModuleApi,
|
|
6006
6104
|
effectType,
|
|
6007
6105
|
strictEffectType,
|
|
6008
6106
|
layerType,
|
|
@@ -6012,7 +6110,7 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
6012
6110
|
effectGen,
|
|
6013
6111
|
effectFnUntracedGen,
|
|
6014
6112
|
effectFnGen,
|
|
6015
|
-
|
|
6113
|
+
extendsCauseYieldableError,
|
|
6016
6114
|
unnecessaryEffectGen: unnecessaryEffectGen2,
|
|
6017
6115
|
effectSchemaType,
|
|
6018
6116
|
contextTag,
|
|
@@ -6028,7 +6126,8 @@ function make7(ts, tsUtils, typeChecker, typeCheckerUtils, program) {
|
|
|
6028
6126
|
extendsSchemaTaggedError,
|
|
6029
6127
|
extendsDataTaggedError,
|
|
6030
6128
|
extendsDataTaggedClass,
|
|
6031
|
-
extendsSchemaTaggedRequest
|
|
6129
|
+
extendsSchemaTaggedRequest,
|
|
6130
|
+
extendsEffectSqlModelClass
|
|
6032
6131
|
};
|
|
6033
6132
|
}
|
|
6034
6133
|
|
|
@@ -6427,7 +6526,8 @@ var annotate = createCodegen({
|
|
|
6427
6526
|
}
|
|
6428
6527
|
for (const variableDeclaration of variableDeclarations) {
|
|
6429
6528
|
if (!variableDeclaration.initializer) continue;
|
|
6430
|
-
const initializerType =
|
|
6529
|
+
const initializerType = typeCheckerUtils.getTypeAtLocation(variableDeclaration.initializer);
|
|
6530
|
+
if (!initializerType) continue;
|
|
6431
6531
|
const enclosingNode = ts.findAncestor(variableDeclaration, (_) => tsUtils.isDeclarationKind(_.kind)) || sourceFile;
|
|
6432
6532
|
const initializerTypeNode = fromNullable(typeCheckerUtils.typeToSimplifiedTypeNode(
|
|
6433
6533
|
initializerType,
|
|
@@ -6879,7 +6979,7 @@ var findNodeToProcess = fn("StructuralSchemaGen.findNodeToProcess")(
|
|
|
6879
6979
|
function* (sourceFile, textRange) {
|
|
6880
6980
|
const ts = yield* service(TypeScriptApi);
|
|
6881
6981
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
6882
|
-
const
|
|
6982
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
6883
6983
|
return pipe(
|
|
6884
6984
|
tsUtils.getAncestorNodesInRange(sourceFile, textRange),
|
|
6885
6985
|
filter((node) => ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)),
|
|
@@ -6888,7 +6988,7 @@ var findNodeToProcess = fn("StructuralSchemaGen.findNodeToProcess")(
|
|
|
6888
6988
|
map4((node) => ({
|
|
6889
6989
|
node,
|
|
6890
6990
|
identifier: node.name,
|
|
6891
|
-
type:
|
|
6991
|
+
type: typeCheckerUtils.getTypeAtLocation(node.name),
|
|
6892
6992
|
isExported: node.modifiers ? (ts.getCombinedModifierFlags(node) & ts.ModifierFlags.Export) !== 0 : false
|
|
6893
6993
|
})),
|
|
6894
6994
|
filter(({ type }) => !!type),
|
|
@@ -7066,7 +7166,7 @@ var typeToSchema = createCodegen({
|
|
|
7066
7166
|
)
|
|
7067
7167
|
);
|
|
7068
7168
|
}
|
|
7069
|
-
const type =
|
|
7169
|
+
const type = typeCheckerUtils.getTypeAtLocation(node.name);
|
|
7070
7170
|
if (!type) {
|
|
7071
7171
|
return yield* fail3(
|
|
7072
7172
|
new CodegenNotApplicableError(
|
|
@@ -7227,10 +7327,12 @@ var effectDataClasses = createCompletion({
|
|
|
7227
7327
|
var anyUnknownInErrorContext = createDiagnostic({
|
|
7228
7328
|
name: "anyUnknownInErrorContext",
|
|
7229
7329
|
code: 28,
|
|
7330
|
+
description: "Detects 'any' or 'unknown' types in Effect error or requirements channels",
|
|
7230
7331
|
severity: "off",
|
|
7231
7332
|
apply: fn("anyUnknownInErrorContext.apply")(function* (sourceFile, report) {
|
|
7232
7333
|
const ts = yield* service(TypeScriptApi);
|
|
7233
7334
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
7335
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
7234
7336
|
const typeParser = yield* service(TypeParser);
|
|
7235
7337
|
const isAnyOrUnknown = (type) => (type.flags & ts.TypeFlags.Any) > 0 || (type.flags & ts.TypeFlags.Unknown) > 0;
|
|
7236
7338
|
const matchingNodes = [];
|
|
@@ -7250,7 +7352,8 @@ var anyUnknownInErrorContext = createDiagnostic({
|
|
|
7250
7352
|
if (ts.isParameter(node) || ts.isPropertyDeclaration(node) || ts.isVariableDeclaration(node)) {
|
|
7251
7353
|
if (node.type) {
|
|
7252
7354
|
const typeNode = node.type;
|
|
7253
|
-
const type2 =
|
|
7355
|
+
const type2 = typeCheckerUtils.getTypeAtLocation(node.type);
|
|
7356
|
+
if (!type2) continue;
|
|
7254
7357
|
const expectedEffect = yield* pipe(
|
|
7255
7358
|
typeParser.strictEffectType(type2, node.type),
|
|
7256
7359
|
orElse2(() => typeParser.layerType(type2, typeNode)),
|
|
@@ -7261,11 +7364,7 @@ var anyUnknownInErrorContext = createDiagnostic({
|
|
|
7261
7364
|
}
|
|
7262
7365
|
ts.forEachChild(node, appendNodeToVisit);
|
|
7263
7366
|
if (!ts.isExpression(node)) continue;
|
|
7264
|
-
|
|
7265
|
-
if (node.parent && ts.isJsxOpeningElement(node.parent) && node.parent.tagName === node) continue;
|
|
7266
|
-
if (node.parent && ts.isJsxClosingElement(node.parent) && node.parent.tagName === node) continue;
|
|
7267
|
-
if (node.parent && ts.isJsxAttribute(node.parent) && node.parent.name === node) continue;
|
|
7268
|
-
let type = typeChecker.getTypeAtLocation(node);
|
|
7367
|
+
let type = typeCheckerUtils.getTypeAtLocation(node);
|
|
7269
7368
|
if (ts.isCallExpression(node)) {
|
|
7270
7369
|
const resolvedSignature = typeChecker.getResolvedSignature(node);
|
|
7271
7370
|
if (resolvedSignature) {
|
|
@@ -7331,11 +7430,13 @@ var anyUnknownInErrorContext = createDiagnostic({
|
|
|
7331
7430
|
var catchUnfailableEffect = createDiagnostic({
|
|
7332
7431
|
name: "catchUnfailableEffect",
|
|
7333
7432
|
code: 2,
|
|
7433
|
+
description: "Warns when using error handling on Effects that never fail (error type is 'never')",
|
|
7334
7434
|
severity: "suggestion",
|
|
7335
7435
|
apply: fn("catchUnfailableEffect.apply")(function* (sourceFile, report) {
|
|
7336
7436
|
const ts = yield* service(TypeScriptApi);
|
|
7337
7437
|
const typeParser = yield* service(TypeParser);
|
|
7338
7438
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
7439
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
7339
7440
|
const nodeToVisit = [];
|
|
7340
7441
|
const appendNodeToVisit = (node) => {
|
|
7341
7442
|
nodeToVisit.push(node);
|
|
@@ -7366,7 +7467,7 @@ var catchUnfailableEffect = createDiagnostic({
|
|
|
7366
7467
|
if (argIndex !== -1) {
|
|
7367
7468
|
let effectTypeToCheck;
|
|
7368
7469
|
if (argIndex === 0) {
|
|
7369
|
-
effectTypeToCheck =
|
|
7470
|
+
effectTypeToCheck = typeCheckerUtils.getTypeAtLocation(subject);
|
|
7370
7471
|
} else {
|
|
7371
7472
|
const signature = typeChecker.getResolvedSignature(pipeCallNode);
|
|
7372
7473
|
if (signature) {
|
|
@@ -7405,6 +7506,7 @@ var catchUnfailableEffect = createDiagnostic({
|
|
|
7405
7506
|
var classSelfMismatch = createDiagnostic({
|
|
7406
7507
|
name: "classSelfMismatch",
|
|
7407
7508
|
code: 20,
|
|
7509
|
+
description: "Ensures Self type parameter matches the class name in Service/Tag/Schema classes",
|
|
7408
7510
|
severity: "error",
|
|
7409
7511
|
apply: fn("classSelfMismatch.apply")(function* (sourceFile, report) {
|
|
7410
7512
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -7426,6 +7528,7 @@ var classSelfMismatch = createDiagnostic({
|
|
|
7426
7528
|
orElse2(() => typeParser.extendsSchemaTaggedClass(node)),
|
|
7427
7529
|
orElse2(() => typeParser.extendsSchemaTaggedError(node)),
|
|
7428
7530
|
orElse2(() => typeParser.extendsSchemaTaggedRequest(node)),
|
|
7531
|
+
orElse2(() => typeParser.extendsEffectSqlModelClass(node)),
|
|
7429
7532
|
orElse2(() => void_)
|
|
7430
7533
|
);
|
|
7431
7534
|
if (result) {
|
|
@@ -7469,6 +7572,7 @@ var classSelfMismatch = createDiagnostic({
|
|
|
7469
7572
|
var deterministicKeys = createDiagnostic({
|
|
7470
7573
|
name: "deterministicKeys",
|
|
7471
7574
|
code: 25,
|
|
7575
|
+
description: "Enforces deterministic naming for service/tag/error identifiers based on class names",
|
|
7472
7576
|
severity: "off",
|
|
7473
7577
|
apply: fn("deterministicKeys.apply")(function* (sourceFile, report) {
|
|
7474
7578
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -7589,6 +7693,7 @@ var programResolvedCacheSize = /* @__PURE__ */ new Map();
|
|
|
7589
7693
|
var duplicatePackage = createDiagnostic({
|
|
7590
7694
|
name: "duplicatePackage",
|
|
7591
7695
|
code: 6,
|
|
7696
|
+
description: "Detects when multiple versions of the same Effect package are loaded",
|
|
7592
7697
|
severity: "warning",
|
|
7593
7698
|
apply: fn("duplicatePackage.apply")(function* (sourceFile, report) {
|
|
7594
7699
|
const program = yield* service(TypeScriptProgram);
|
|
@@ -7636,6 +7741,7 @@ ${versions.map((version) => `- found ${version} at ${resolvedPackages[packageNam
|
|
|
7636
7741
|
var effectGenUsesAdapter = createDiagnostic({
|
|
7637
7742
|
name: "effectGenUsesAdapter",
|
|
7638
7743
|
code: 23,
|
|
7744
|
+
description: "Warns when using the deprecated adapter parameter in Effect.gen",
|
|
7639
7745
|
severity: "warning",
|
|
7640
7746
|
apply: fn("effectGenUsesAdapter.apply")(function* (sourceFile, report) {
|
|
7641
7747
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -7673,6 +7779,7 @@ var effectGenUsesAdapter = createDiagnostic({
|
|
|
7673
7779
|
var effectInVoidSuccess = createDiagnostic({
|
|
7674
7780
|
name: "effectInVoidSuccess",
|
|
7675
7781
|
code: 14,
|
|
7782
|
+
description: "Detects nested Effects in void success channels that may cause unexecuted effects",
|
|
7676
7783
|
severity: "warning",
|
|
7677
7784
|
apply: fn("effectInVoidSuccess.apply")(function* (sourceFile, report) {
|
|
7678
7785
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -7721,10 +7828,12 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
7721
7828
|
var floatingEffect = createDiagnostic({
|
|
7722
7829
|
name: "floatingEffect",
|
|
7723
7830
|
code: 3,
|
|
7831
|
+
description: "Ensures Effects are yielded or assigned to variables, not left floating",
|
|
7724
7832
|
severity: "error",
|
|
7725
7833
|
apply: fn("floatingEffect.apply")(function* (sourceFile, report) {
|
|
7726
7834
|
const ts = yield* service(TypeScriptApi);
|
|
7727
7835
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
7836
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
7728
7837
|
const typeParser = yield* service(TypeParser);
|
|
7729
7838
|
function isFloatingExpression(node) {
|
|
7730
7839
|
if (!ts.isExpressionStatement(node)) return false;
|
|
@@ -7743,7 +7852,8 @@ var floatingEffect = createDiagnostic({
|
|
|
7743
7852
|
const node = nodeToVisit.shift();
|
|
7744
7853
|
ts.forEachChild(node, appendNodeToVisit);
|
|
7745
7854
|
if (!isFloatingExpression(node)) continue;
|
|
7746
|
-
const type =
|
|
7855
|
+
const type = typeCheckerUtils.getTypeAtLocation(node.expression);
|
|
7856
|
+
if (!type) continue;
|
|
7747
7857
|
const effect = yield* option(typeParser.effectType(type, node.expression));
|
|
7748
7858
|
if (isSome2(effect)) {
|
|
7749
7859
|
const allowedFloatingEffects = yield* pipe(
|
|
@@ -7769,6 +7879,7 @@ var floatingEffect = createDiagnostic({
|
|
|
7769
7879
|
var genericEffectServices = createDiagnostic({
|
|
7770
7880
|
name: "genericEffectServices",
|
|
7771
7881
|
code: 10,
|
|
7882
|
+
description: "Prevents services with type parameters that cannot be discriminated at runtime",
|
|
7772
7883
|
severity: "warning",
|
|
7773
7884
|
apply: fn("genericEffectServices.apply")(function* (sourceFile, report) {
|
|
7774
7885
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -7811,10 +7922,56 @@ var genericEffectServices = createDiagnostic({
|
|
|
7811
7922
|
})
|
|
7812
7923
|
});
|
|
7813
7924
|
|
|
7925
|
+
// src/diagnostics/globalErrorInEffectFailure.ts
|
|
7926
|
+
var globalErrorInEffectFailure = createDiagnostic({
|
|
7927
|
+
name: "globalErrorInEffectFailure",
|
|
7928
|
+
code: 35,
|
|
7929
|
+
description: "Warns when Effect.fail is called with the global Error type",
|
|
7930
|
+
severity: "warning",
|
|
7931
|
+
apply: fn("globalErrorInEffectFailure.apply")(function* (sourceFile, report) {
|
|
7932
|
+
const ts = yield* service(TypeScriptApi);
|
|
7933
|
+
const typeParser = yield* service(TypeParser);
|
|
7934
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
7935
|
+
const nodeToVisit = [];
|
|
7936
|
+
const appendNodeToVisit = (node) => {
|
|
7937
|
+
nodeToVisit.push(node);
|
|
7938
|
+
return void 0;
|
|
7939
|
+
};
|
|
7940
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
7941
|
+
while (nodeToVisit.length > 0) {
|
|
7942
|
+
const node = nodeToVisit.shift();
|
|
7943
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
7944
|
+
if (ts.isCallExpression(node)) {
|
|
7945
|
+
yield* pipe(
|
|
7946
|
+
typeParser.isNodeReferenceToEffectModuleApi("fail")(node.expression),
|
|
7947
|
+
flatMap4(() => {
|
|
7948
|
+
if (node.arguments.length > 0) {
|
|
7949
|
+
const failArgument = node.arguments[0];
|
|
7950
|
+
const argumentType = typeCheckerUtils.getTypeAtLocation(failArgument);
|
|
7951
|
+
if (argumentType && typeCheckerUtils.isGlobalErrorType(argumentType)) {
|
|
7952
|
+
return sync(
|
|
7953
|
+
() => report({
|
|
7954
|
+
location: node,
|
|
7955
|
+
messageText: `Effect.fail is called with the global Error type. It's not recommended to use the global Error type in Effect failures as they can get merged together. Instead, use tagged errors (Data.TaggedError) or custom errors with a discriminator property to get properly type-checked errors.`,
|
|
7956
|
+
fixes: []
|
|
7957
|
+
})
|
|
7958
|
+
);
|
|
7959
|
+
}
|
|
7960
|
+
}
|
|
7961
|
+
return void_;
|
|
7962
|
+
}),
|
|
7963
|
+
ignore
|
|
7964
|
+
);
|
|
7965
|
+
}
|
|
7966
|
+
}
|
|
7967
|
+
})
|
|
7968
|
+
});
|
|
7969
|
+
|
|
7814
7970
|
// src/diagnostics/importFromBarrel.ts
|
|
7815
7971
|
var importFromBarrel = createDiagnostic({
|
|
7816
7972
|
name: "importFromBarrel",
|
|
7817
7973
|
code: 12,
|
|
7974
|
+
description: "Suggests importing from specific module paths instead of barrel exports",
|
|
7818
7975
|
severity: "off",
|
|
7819
7976
|
apply: fn("importFromBarrel.apply")(function* (sourceFile, report) {
|
|
7820
7977
|
const languageServicePluginOptions = yield* service(LanguageServicePluginOptions);
|
|
@@ -7954,6 +8111,7 @@ var importFromBarrel = createDiagnostic({
|
|
|
7954
8111
|
var leakingRequirements = createDiagnostic({
|
|
7955
8112
|
name: "leakingRequirements",
|
|
7956
8113
|
code: 8,
|
|
8114
|
+
description: "Detects implementation services leaked in service methods",
|
|
7957
8115
|
severity: "suggestion",
|
|
7958
8116
|
apply: fn("leakingRequirements.apply")(function* (sourceFile, report) {
|
|
7959
8117
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -8061,7 +8219,8 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
|
|
|
8061
8219
|
const node = nodeToVisit.shift();
|
|
8062
8220
|
const typesToCheck = [];
|
|
8063
8221
|
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && ts.idText(node.expression.name) === "GenericTag") {
|
|
8064
|
-
|
|
8222
|
+
const nodeType = typeCheckerUtils.getTypeAtLocation(node);
|
|
8223
|
+
if (nodeType) typesToCheck.push([nodeType, node]);
|
|
8065
8224
|
} else if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
8066
8225
|
const classSym = typeChecker.getSymbolAtLocation(node.name);
|
|
8067
8226
|
if (classSym) {
|
|
@@ -8095,10 +8254,12 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
|
|
|
8095
8254
|
var missedPipeableOpportunity = createDiagnostic({
|
|
8096
8255
|
name: "missedPipeableOpportunity",
|
|
8097
8256
|
code: 26,
|
|
8257
|
+
description: "Enforces the use of pipeable style for nested function calls",
|
|
8098
8258
|
severity: "off",
|
|
8099
8259
|
apply: fn("missedPipeableOpportunity.apply")(function* (sourceFile, report) {
|
|
8100
8260
|
const ts = yield* service(TypeScriptApi);
|
|
8101
8261
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
8262
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
8102
8263
|
const typeParser = yield* service(TypeParser);
|
|
8103
8264
|
const options = yield* service(LanguageServicePluginOptions);
|
|
8104
8265
|
const nodeToVisit = [sourceFile];
|
|
@@ -8129,7 +8290,8 @@ var missedPipeableOpportunity = createDiagnostic({
|
|
|
8129
8290
|
const originalParentChain = parentChain.slice();
|
|
8130
8291
|
while (parentChain.length > options.pipeableMinArgCount) {
|
|
8131
8292
|
const subject = parentChain.pop();
|
|
8132
|
-
const resultType =
|
|
8293
|
+
const resultType = typeCheckerUtils.getTypeAtLocation(subject);
|
|
8294
|
+
if (!resultType) continue;
|
|
8133
8295
|
const pipeableType = yield* pipe(typeParser.pipeableType(resultType, subject), orElse2(() => void_));
|
|
8134
8296
|
if (pipeableType) {
|
|
8135
8297
|
report({
|
|
@@ -8174,6 +8336,7 @@ var missedPipeableOpportunity = createDiagnostic({
|
|
|
8174
8336
|
var missingEffectContext = createDiagnostic({
|
|
8175
8337
|
name: "missingEffectContext",
|
|
8176
8338
|
code: 1,
|
|
8339
|
+
description: "Reports missing service requirements in Effect context channel",
|
|
8177
8340
|
severity: "error",
|
|
8178
8341
|
apply: fn("missingEffectContext.apply")(function* (sourceFile, report) {
|
|
8179
8342
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
@@ -8222,6 +8385,7 @@ var missingEffectContext = createDiagnostic({
|
|
|
8222
8385
|
var missingEffectError = createDiagnostic({
|
|
8223
8386
|
name: "missingEffectError",
|
|
8224
8387
|
code: 1,
|
|
8388
|
+
description: "Reports missing error types in Effect error channel",
|
|
8225
8389
|
severity: "error",
|
|
8226
8390
|
apply: fn("missingEffectError.apply")(function* (sourceFile, report) {
|
|
8227
8391
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -8361,6 +8525,7 @@ var missingEffectError = createDiagnostic({
|
|
|
8361
8525
|
var missingEffectServiceDependency = createDiagnostic({
|
|
8362
8526
|
name: "missingEffectServiceDependency",
|
|
8363
8527
|
code: 22,
|
|
8528
|
+
description: "Checks that Effect.Service dependencies satisfy all required layer inputs",
|
|
8364
8529
|
severity: "off",
|
|
8365
8530
|
apply: fn("missingEffectServiceDependency.apply")(function* (sourceFile, report) {
|
|
8366
8531
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -8402,13 +8567,15 @@ var missingEffectServiceDependency = createDiagnostic({
|
|
|
8402
8567
|
excludeNever
|
|
8403
8568
|
);
|
|
8404
8569
|
const providedIndexes = /* @__PURE__ */ new Set();
|
|
8405
|
-
const optionsType = typeChecker.getTypeAtLocation(options);
|
|
8406
|
-
const dependenciesProperty = typeChecker.getPropertyOfType(optionsType, "dependencies");
|
|
8407
8570
|
let types = [];
|
|
8408
|
-
|
|
8409
|
-
|
|
8410
|
-
const
|
|
8411
|
-
|
|
8571
|
+
const optionsType = typeCheckerUtils.getTypeAtLocation(options);
|
|
8572
|
+
if (optionsType) {
|
|
8573
|
+
const dependenciesProperty = typeChecker.getPropertyOfType(optionsType, "dependencies");
|
|
8574
|
+
if (dependenciesProperty) {
|
|
8575
|
+
const dependenciesTypes = typeChecker.getTypeOfSymbolAtLocation(dependenciesProperty, options);
|
|
8576
|
+
const numberIndexType = typeChecker.getIndexTypeOfType(dependenciesTypes, ts.IndexKind.Number);
|
|
8577
|
+
types = numberIndexType ? typeCheckerUtils.unrollUnionMembers(numberIndexType) : [];
|
|
8578
|
+
}
|
|
8412
8579
|
}
|
|
8413
8580
|
for (const depType of types) {
|
|
8414
8581
|
const depLayerResult = yield* pipe(
|
|
@@ -8451,10 +8618,11 @@ var missingEffectServiceDependency = createDiagnostic({
|
|
|
8451
8618
|
var missingReturnYieldStar = createDiagnostic({
|
|
8452
8619
|
name: "missingReturnYieldStar",
|
|
8453
8620
|
code: 7,
|
|
8621
|
+
description: "Suggests using 'return yield*' for Effects with never success for better type narrowing",
|
|
8454
8622
|
severity: "error",
|
|
8455
8623
|
apply: fn("missingReturnYieldStar.apply")(function* (sourceFile, report) {
|
|
8456
8624
|
const ts = yield* service(TypeScriptApi);
|
|
8457
|
-
const
|
|
8625
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
8458
8626
|
const typeParser = yield* service(TypeParser);
|
|
8459
8627
|
const nodeToVisit = [];
|
|
8460
8628
|
const appendNodeToVisit = (node) => {
|
|
@@ -8466,42 +8634,44 @@ var missingReturnYieldStar = createDiagnostic({
|
|
|
8466
8634
|
const node = nodeToVisit.shift();
|
|
8467
8635
|
ts.forEachChild(node, appendNodeToVisit);
|
|
8468
8636
|
if (ts.isYieldExpression(node) && node.expression && node.asteriskToken) {
|
|
8469
|
-
const type =
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
if (generatorFunctionOrReturnStatement && generatorFunctionOrReturnStatement.
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
|
|
8495
|
-
|
|
8496
|
-
|
|
8497
|
-
|
|
8498
|
-
|
|
8499
|
-
|
|
8500
|
-
|
|
8501
|
-
|
|
8502
|
-
|
|
8503
|
-
|
|
8504
|
-
|
|
8637
|
+
const type = typeCheckerUtils.getTypeAtLocation(node.expression);
|
|
8638
|
+
if (type) {
|
|
8639
|
+
const maybeEffect = yield* option(typeParser.effectType(type, node.expression));
|
|
8640
|
+
if (isSome2(maybeEffect) && maybeEffect.value.A.flags & ts.TypeFlags.Never) {
|
|
8641
|
+
const generatorFunctionOrReturnStatement = ts.findAncestor(
|
|
8642
|
+
node,
|
|
8643
|
+
(_) => ts.isFunctionExpression(_) || ts.isFunctionDeclaration(_) || ts.isMethodDeclaration(_) || ts.isReturnStatement(_) || ts.isThrowStatement(_)
|
|
8644
|
+
);
|
|
8645
|
+
if (generatorFunctionOrReturnStatement && !ts.isReturnStatement(generatorFunctionOrReturnStatement) && !ts.isThrowStatement(generatorFunctionOrReturnStatement)) {
|
|
8646
|
+
if (generatorFunctionOrReturnStatement && generatorFunctionOrReturnStatement.parent) {
|
|
8647
|
+
const effectGenNode = generatorFunctionOrReturnStatement.parent;
|
|
8648
|
+
const effectGenLike = yield* pipe(
|
|
8649
|
+
typeParser.effectGen(effectGenNode),
|
|
8650
|
+
orElse2(() => typeParser.effectFnUntracedGen(effectGenNode)),
|
|
8651
|
+
orElse2(() => typeParser.effectFnGen(effectGenNode)),
|
|
8652
|
+
option
|
|
8653
|
+
);
|
|
8654
|
+
if (isSome2(effectGenLike)) {
|
|
8655
|
+
const fix = node.expression ? [{
|
|
8656
|
+
fixName: "missingReturnYieldStar_fix",
|
|
8657
|
+
description: "Add return statement",
|
|
8658
|
+
apply: gen(function* () {
|
|
8659
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
8660
|
+
changeTracker.replaceNode(
|
|
8661
|
+
sourceFile,
|
|
8662
|
+
node,
|
|
8663
|
+
ts.factory.createReturnStatement(
|
|
8664
|
+
node
|
|
8665
|
+
)
|
|
8666
|
+
);
|
|
8667
|
+
})
|
|
8668
|
+
}] : [];
|
|
8669
|
+
report({
|
|
8670
|
+
location: node,
|
|
8671
|
+
messageText: `It is recommended to use return yield* for Effects that never succeed to signal a definitive exit point for type narrowing and tooling support.`,
|
|
8672
|
+
fixes: fix
|
|
8673
|
+
});
|
|
8674
|
+
}
|
|
8505
8675
|
}
|
|
8506
8676
|
}
|
|
8507
8677
|
}
|
|
@@ -8515,6 +8685,7 @@ var missingReturnYieldStar = createDiagnostic({
|
|
|
8515
8685
|
var missingStarInYieldEffectGen = createDiagnostic({
|
|
8516
8686
|
name: "missingStarInYieldEffectGen",
|
|
8517
8687
|
code: 4,
|
|
8688
|
+
description: "Enforces using 'yield*' instead of 'yield' when yielding Effects in generators",
|
|
8518
8689
|
severity: "error",
|
|
8519
8690
|
apply: fn("missingStarInYieldEffectGen.apply")(function* (sourceFile, report) {
|
|
8520
8691
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -8589,11 +8760,12 @@ var missingStarInYieldEffectGen = createDiagnostic({
|
|
|
8589
8760
|
var multipleEffectProvide = createDiagnostic({
|
|
8590
8761
|
name: "multipleEffectProvide",
|
|
8591
8762
|
code: 18,
|
|
8763
|
+
description: "Warns against chaining Effect.provide calls which can cause service lifecycle issues",
|
|
8592
8764
|
severity: "warning",
|
|
8593
8765
|
apply: fn("multipleEffectProvide.apply")(function* (sourceFile, report) {
|
|
8594
8766
|
const ts = yield* service(TypeScriptApi);
|
|
8595
8767
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
8596
|
-
const
|
|
8768
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
8597
8769
|
const typeParser = yield* service(TypeParser);
|
|
8598
8770
|
const effectModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
8599
8771
|
sourceFile,
|
|
@@ -8608,7 +8780,8 @@ var multipleEffectProvide = createDiagnostic({
|
|
|
8608
8780
|
const parseEffectProvideLayer = (node) => {
|
|
8609
8781
|
if (ts.isCallExpression(node) && node.arguments.length > 0) {
|
|
8610
8782
|
const layer = node.arguments[0];
|
|
8611
|
-
const type =
|
|
8783
|
+
const type = typeCheckerUtils.getTypeAtLocation(layer);
|
|
8784
|
+
if (!type) return void_;
|
|
8612
8785
|
return pipe(
|
|
8613
8786
|
typeParser.isNodeReferenceToEffectModuleApi("provide")(node.expression),
|
|
8614
8787
|
flatMap4(() => typeParser.layerType(type, layer)),
|
|
@@ -8686,6 +8859,7 @@ var multipleEffectProvide = createDiagnostic({
|
|
|
8686
8859
|
var nonObjectEffectServiceType = createDiagnostic({
|
|
8687
8860
|
name: "nonObjectEffectServiceType",
|
|
8688
8861
|
code: 24,
|
|
8862
|
+
description: "Ensures Effect.Service types are objects, not primitives",
|
|
8689
8863
|
severity: "error",
|
|
8690
8864
|
apply: fn("nonObjectEffectServiceType.apply")(function* (sourceFile, report) {
|
|
8691
8865
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -8724,12 +8898,13 @@ var nonObjectEffectServiceType = createDiagnostic({
|
|
|
8724
8898
|
fixes: []
|
|
8725
8899
|
};
|
|
8726
8900
|
if (propertyName === "succeed") {
|
|
8727
|
-
const valueType =
|
|
8728
|
-
if (isPrimitiveType(valueType)) {
|
|
8901
|
+
const valueType = typeCheckerUtils.getTypeAtLocation(propertyValue);
|
|
8902
|
+
if (valueType && isPrimitiveType(valueType)) {
|
|
8729
8903
|
report(errorToReport);
|
|
8730
8904
|
}
|
|
8731
8905
|
} else if (propertyName === "sync") {
|
|
8732
|
-
const valueType =
|
|
8906
|
+
const valueType = typeCheckerUtils.getTypeAtLocation(propertyValue);
|
|
8907
|
+
if (!valueType) continue;
|
|
8733
8908
|
const signatures = typeChecker.getSignaturesOfType(valueType, ts.SignatureKind.Call);
|
|
8734
8909
|
for (const signature of signatures) {
|
|
8735
8910
|
const returnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
@@ -8739,7 +8914,8 @@ var nonObjectEffectServiceType = createDiagnostic({
|
|
|
8739
8914
|
}
|
|
8740
8915
|
}
|
|
8741
8916
|
} else if (propertyName === "effect" || propertyName === "scoped") {
|
|
8742
|
-
const valueType =
|
|
8917
|
+
const valueType = typeCheckerUtils.getTypeAtLocation(propertyValue);
|
|
8918
|
+
if (!valueType) continue;
|
|
8743
8919
|
const effectResult = yield* pipe(
|
|
8744
8920
|
typeParser.effectType(valueType, propertyValue),
|
|
8745
8921
|
orElse2(() => void_)
|
|
@@ -8776,6 +8952,7 @@ var nonObjectEffectServiceType = createDiagnostic({
|
|
|
8776
8952
|
var outdatedEffectCodegen = createDiagnostic({
|
|
8777
8953
|
name: "outdatedEffectCodegen",
|
|
8778
8954
|
code: 19,
|
|
8955
|
+
description: "Detects when generated code is outdated and needs to be regenerated",
|
|
8779
8956
|
severity: "warning",
|
|
8780
8957
|
apply: fn("outdatedEffectCodegen.apply")(function* (sourceFile, _report) {
|
|
8781
8958
|
const codegensWithRanges = yield* getCodegensForSourceFile(codegens, sourceFile);
|
|
@@ -8821,11 +8998,12 @@ var outdatedEffectCodegen = createDiagnostic({
|
|
|
8821
8998
|
var overriddenSchemaConstructor = createDiagnostic({
|
|
8822
8999
|
name: "overriddenSchemaConstructor",
|
|
8823
9000
|
code: 30,
|
|
9001
|
+
description: "Prevents overriding constructors in Schema classes which breaks decoding behavior",
|
|
8824
9002
|
severity: "error",
|
|
8825
9003
|
apply: fn("overriddenSchemaConstructor.apply")(function* (sourceFile, report) {
|
|
8826
9004
|
const ts = yield* service(TypeScriptApi);
|
|
8827
9005
|
const typeParser = yield* service(TypeParser);
|
|
8828
|
-
const
|
|
9006
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
8829
9007
|
function isAllowedConstructor(node) {
|
|
8830
9008
|
if (node.body && node.body.statements.length === 1) {
|
|
8831
9009
|
const expressionStatement = node.body.statements[0];
|
|
@@ -8859,7 +9037,8 @@ var overriddenSchemaConstructor = createDiagnostic({
|
|
|
8859
9037
|
for (const heritageClause of node.heritageClauses) {
|
|
8860
9038
|
if (heritageClause.token === ts.SyntaxKind.ExtendsKeyword) {
|
|
8861
9039
|
for (const type of heritageClause.types) {
|
|
8862
|
-
const typeAtLocation =
|
|
9040
|
+
const typeAtLocation = typeCheckerUtils.getTypeAtLocation(type.expression);
|
|
9041
|
+
if (!typeAtLocation) continue;
|
|
8863
9042
|
const isSchema = yield* pipe(
|
|
8864
9043
|
typeParser.effectSchemaType(typeAtLocation, type.expression),
|
|
8865
9044
|
map8(() => true),
|
|
@@ -8956,10 +9135,11 @@ var overriddenSchemaConstructor = createDiagnostic({
|
|
|
8956
9135
|
var returnEffectInGen = createDiagnostic({
|
|
8957
9136
|
name: "returnEffectInGen",
|
|
8958
9137
|
code: 11,
|
|
9138
|
+
description: "Warns when returning an Effect in a generator causes nested Effect<Effect<...>>",
|
|
8959
9139
|
severity: "suggestion",
|
|
8960
9140
|
apply: fn("returnEffectInGen.apply")(function* (sourceFile, report) {
|
|
8961
9141
|
const ts = yield* service(TypeScriptApi);
|
|
8962
|
-
const
|
|
9142
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
8963
9143
|
const typeParser = yield* service(TypeParser);
|
|
8964
9144
|
const nodeToVisit = [];
|
|
8965
9145
|
const appendNodeToVisit = (node) => {
|
|
@@ -8977,7 +9157,8 @@ var returnEffectInGen = createDiagnostic({
|
|
|
8977
9157
|
(_) => ts.isFunctionExpression(_) || ts.isFunctionDeclaration(_) || ts.isMethodDeclaration(_) || ts.isArrowFunction(_) || ts.isGetAccessor(_)
|
|
8978
9158
|
);
|
|
8979
9159
|
if (!(generatorOrRegularFunction && "asteriskToken" in generatorOrRegularFunction && generatorOrRegularFunction.asteriskToken)) continue;
|
|
8980
|
-
const type =
|
|
9160
|
+
const type = typeCheckerUtils.getTypeAtLocation(node.expression);
|
|
9161
|
+
if (!type) continue;
|
|
8981
9162
|
const maybeEffect = yield* option(typeParser.strictEffectType(type, node.expression));
|
|
8982
9163
|
if (isSome2(maybeEffect)) {
|
|
8983
9164
|
if (generatorOrRegularFunction && generatorOrRegularFunction.parent) {
|
|
@@ -9023,6 +9204,7 @@ Nested Effect-able types may be intended if you plan to later manually flatten o
|
|
|
9023
9204
|
var runEffectInsideEffect = createDiagnostic({
|
|
9024
9205
|
name: "runEffectInsideEffect",
|
|
9025
9206
|
code: 32,
|
|
9207
|
+
description: "Suggests using Runtime methods instead of Effect.run* inside Effect contexts",
|
|
9026
9208
|
severity: "suggestion",
|
|
9027
9209
|
apply: fn("runEffectInsideEffect.apply")(function* (sourceFile, report) {
|
|
9028
9210
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9162,6 +9344,7 @@ Consider extracting the Runtime by using for example Effect.runtime and then use
|
|
|
9162
9344
|
var schemaStructWithTag = createDiagnostic({
|
|
9163
9345
|
name: "schemaStructWithTag",
|
|
9164
9346
|
code: 34,
|
|
9347
|
+
description: "Suggests using Schema.TaggedStruct instead of Schema.Struct with _tag field",
|
|
9165
9348
|
severity: "suggestion",
|
|
9166
9349
|
apply: fn("schemaStructWithTag.apply")(function* (sourceFile, report) {
|
|
9167
9350
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9241,6 +9424,7 @@ var schemaStructWithTag = createDiagnostic({
|
|
|
9241
9424
|
var schemaUnionOfLiterals = createDiagnostic({
|
|
9242
9425
|
name: "schemaUnionOfLiterals",
|
|
9243
9426
|
code: 33,
|
|
9427
|
+
description: "Simplifies Schema.Union of multiple Schema.Literal calls into single Schema.Literal",
|
|
9244
9428
|
severity: "off",
|
|
9245
9429
|
apply: fn("schemaUnionOfLiterals.apply")(function* (sourceFile, report) {
|
|
9246
9430
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9314,6 +9498,7 @@ var schemaUnionOfLiterals = createDiagnostic({
|
|
|
9314
9498
|
var scopeInLayerEffect = createDiagnostic({
|
|
9315
9499
|
name: "scopeInLayerEffect",
|
|
9316
9500
|
code: 13,
|
|
9501
|
+
description: "Suggests using Layer.scoped instead of Layer.effect when Scope is in requirements",
|
|
9317
9502
|
severity: "warning",
|
|
9318
9503
|
apply: fn("scopeInLayerEffect.apply")(function* (sourceFile, report) {
|
|
9319
9504
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9372,12 +9557,14 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
9372
9557
|
const node = nodeToVisit.shift();
|
|
9373
9558
|
const layerEffectApiCall = parseLayerEffectApiCall(node);
|
|
9374
9559
|
if (layerEffectApiCall) {
|
|
9375
|
-
const type =
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9560
|
+
const type = typeCheckerUtils.getTypeAtLocation(node);
|
|
9561
|
+
if (type) {
|
|
9562
|
+
yield* pipe(
|
|
9563
|
+
typeParser.layerType(type, node),
|
|
9564
|
+
flatMap4(({ RIn }) => reportIfLayerRequireScope(RIn, node, layerEffectApiCall.methodIdentifier)),
|
|
9565
|
+
ignore
|
|
9566
|
+
);
|
|
9567
|
+
}
|
|
9381
9568
|
continue;
|
|
9382
9569
|
}
|
|
9383
9570
|
if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
@@ -9405,6 +9592,7 @@ Consider using "scoped" instead to get rid of the scope in the requirements.`,
|
|
|
9405
9592
|
var strictBooleanExpressions = createDiagnostic({
|
|
9406
9593
|
name: "strictBooleanExpressions",
|
|
9407
9594
|
code: 17,
|
|
9595
|
+
description: "Enforces boolean types in conditional expressions for type safety",
|
|
9408
9596
|
severity: "off",
|
|
9409
9597
|
apply: fn("strictBooleanExpressions.apply")(function* (sourceFile, report) {
|
|
9410
9598
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9446,7 +9634,8 @@ var strictBooleanExpressions = createDiagnostic({
|
|
|
9446
9634
|
if (!nodeToCheck) continue;
|
|
9447
9635
|
if (!conditionChecks.has(nodeToCheck.parent)) continue;
|
|
9448
9636
|
if (!ts.isExpression(nodeToCheck)) continue;
|
|
9449
|
-
const nodeType =
|
|
9637
|
+
const nodeType = typeCheckerUtils.getTypeAtLocation(nodeToCheck);
|
|
9638
|
+
if (!nodeType) continue;
|
|
9450
9639
|
const constrainedType = typeChecker.getBaseConstraintOfType(nodeType);
|
|
9451
9640
|
let typesToCheck = [constrainedType || nodeType];
|
|
9452
9641
|
while (typesToCheck.length > 0) {
|
|
@@ -9474,10 +9663,11 @@ var strictBooleanExpressions = createDiagnostic({
|
|
|
9474
9663
|
var strictEffectProvide = createDiagnostic({
|
|
9475
9664
|
name: "strictEffectProvide",
|
|
9476
9665
|
code: 27,
|
|
9666
|
+
description: "Warns when using Effect.provide with layers outside of application entry points",
|
|
9477
9667
|
severity: "off",
|
|
9478
9668
|
apply: fn("strictEffectProvide.apply")(function* (sourceFile, report) {
|
|
9479
9669
|
const ts = yield* service(TypeScriptApi);
|
|
9480
|
-
const
|
|
9670
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
9481
9671
|
const typeParser = yield* service(TypeParser);
|
|
9482
9672
|
const parseEffectProvideWithLayer = (node) => gen(function* () {
|
|
9483
9673
|
if (!ts.isCallExpression(node) || node.arguments.length === 0) {
|
|
@@ -9486,7 +9676,8 @@ var strictEffectProvide = createDiagnostic({
|
|
|
9486
9676
|
yield* typeParser.isNodeReferenceToEffectModuleApi("provide")(node.expression);
|
|
9487
9677
|
return yield* firstSuccessOf(
|
|
9488
9678
|
node.arguments.map((arg) => {
|
|
9489
|
-
const argType =
|
|
9679
|
+
const argType = typeCheckerUtils.getTypeAtLocation(arg);
|
|
9680
|
+
if (!argType) return typeParserIssue("Could not get argument type");
|
|
9490
9681
|
return typeParser.layerType(argType, arg);
|
|
9491
9682
|
})
|
|
9492
9683
|
);
|
|
@@ -9518,6 +9709,7 @@ var strictEffectProvide = createDiagnostic({
|
|
|
9518
9709
|
var tryCatchInEffectGen = createDiagnostic({
|
|
9519
9710
|
name: "tryCatchInEffectGen",
|
|
9520
9711
|
code: 15,
|
|
9712
|
+
description: "Discourages try/catch in Effect generators in favor of Effect error handling",
|
|
9521
9713
|
severity: "suggestion",
|
|
9522
9714
|
apply: fn("tryCatchInEffectGen.apply")(function* (sourceFile, report) {
|
|
9523
9715
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9563,6 +9755,7 @@ var tryCatchInEffectGen = createDiagnostic({
|
|
|
9563
9755
|
var unknownInEffectCatch = createDiagnostic({
|
|
9564
9756
|
name: "unknownInEffectCatch",
|
|
9565
9757
|
code: 31,
|
|
9758
|
+
description: "Warns when catch callbacks return unknown instead of typed errors",
|
|
9566
9759
|
severity: "warning",
|
|
9567
9760
|
apply: fn("unknownInEffectCatch.apply")(function* (sourceFile, report) {
|
|
9568
9761
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9620,6 +9813,7 @@ Consider wrapping unknown errors into Effect's Data.TaggedError for example, or
|
|
|
9620
9813
|
var unnecessaryEffectGen = createDiagnostic({
|
|
9621
9814
|
name: "unnecessaryEffectGen",
|
|
9622
9815
|
code: 5,
|
|
9816
|
+
description: "Suggests removing Effect.gen when it contains only a single return statement",
|
|
9623
9817
|
severity: "suggestion",
|
|
9624
9818
|
apply: fn("unnecessaryEffectGen.apply")(function* (sourceFile, report) {
|
|
9625
9819
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9663,15 +9857,12 @@ var unnecessaryEffectGen = createDiagnostic({
|
|
|
9663
9857
|
var unnecessaryFailYieldableError = createDiagnostic({
|
|
9664
9858
|
name: "unnecessaryFailYieldableError",
|
|
9665
9859
|
code: 29,
|
|
9860
|
+
description: "Suggests yielding yieldable errors directly instead of wrapping with Effect.fail",
|
|
9666
9861
|
severity: "suggestion",
|
|
9667
9862
|
apply: fn("unnecessaryFailYieldableError.apply")(function* (sourceFile, report) {
|
|
9668
9863
|
const ts = yield* service(TypeScriptApi);
|
|
9669
9864
|
const typeParser = yield* service(TypeParser);
|
|
9670
|
-
const
|
|
9671
|
-
const yieldableErrorTypes = yield* pipe(
|
|
9672
|
-
typeParser.effectCauseYieldableErrorTypes(sourceFile),
|
|
9673
|
-
orElse2(() => succeed([]))
|
|
9674
|
-
);
|
|
9865
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
9675
9866
|
const nodeToVisit = [];
|
|
9676
9867
|
const appendNodeToVisit = (node) => {
|
|
9677
9868
|
nodeToVisit.push(node);
|
|
@@ -9685,32 +9876,34 @@ var unnecessaryFailYieldableError = createDiagnostic({
|
|
|
9685
9876
|
const callExpression = node.expression;
|
|
9686
9877
|
yield* pipe(
|
|
9687
9878
|
typeParser.isNodeReferenceToEffectModuleApi("fail")(callExpression.expression),
|
|
9688
|
-
|
|
9879
|
+
flatMap4(() => {
|
|
9689
9880
|
if (callExpression.arguments.length > 0) {
|
|
9690
9881
|
const failArgument = callExpression.arguments[0];
|
|
9691
|
-
const argumentType =
|
|
9692
|
-
|
|
9693
|
-
|
|
9882
|
+
const argumentType = typeCheckerUtils.getTypeAtLocation(failArgument);
|
|
9883
|
+
if (!argumentType) return void_;
|
|
9884
|
+
return pipe(
|
|
9885
|
+
typeParser.extendsCauseYieldableError(argumentType),
|
|
9886
|
+
map8(
|
|
9887
|
+
() => report({
|
|
9888
|
+
location: node,
|
|
9889
|
+
messageText: `This Effect.fail call uses a yieldable error type as argument. You can yield* the error directly instead.`,
|
|
9890
|
+
fixes: [{
|
|
9891
|
+
fixName: "unnecessaryFailYieldableError_fix",
|
|
9892
|
+
description: "Replace yield* Effect.fail with yield*",
|
|
9893
|
+
apply: gen(function* () {
|
|
9894
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
9895
|
+
changeTracker.replaceNode(
|
|
9896
|
+
sourceFile,
|
|
9897
|
+
callExpression,
|
|
9898
|
+
failArgument
|
|
9899
|
+
);
|
|
9900
|
+
})
|
|
9901
|
+
}]
|
|
9902
|
+
})
|
|
9903
|
+
)
|
|
9694
9904
|
);
|
|
9695
|
-
if (isYieldableError) {
|
|
9696
|
-
report({
|
|
9697
|
-
location: node,
|
|
9698
|
-
messageText: `This Effect.fail call uses a yieldable error type as argument. You can yield* the error directly instead.`,
|
|
9699
|
-
fixes: [{
|
|
9700
|
-
fixName: "unnecessaryFailYieldableError_fix",
|
|
9701
|
-
description: "Replace yield* Effect.fail with yield*",
|
|
9702
|
-
apply: gen(function* () {
|
|
9703
|
-
const changeTracker = yield* service(ChangeTracker);
|
|
9704
|
-
changeTracker.replaceNode(
|
|
9705
|
-
sourceFile,
|
|
9706
|
-
callExpression,
|
|
9707
|
-
failArgument
|
|
9708
|
-
);
|
|
9709
|
-
})
|
|
9710
|
-
}]
|
|
9711
|
-
});
|
|
9712
|
-
}
|
|
9713
9905
|
}
|
|
9906
|
+
return void_;
|
|
9714
9907
|
}),
|
|
9715
9908
|
ignore
|
|
9716
9909
|
);
|
|
@@ -9723,6 +9916,7 @@ var unnecessaryFailYieldableError = createDiagnostic({
|
|
|
9723
9916
|
var unnecessaryPipe = createDiagnostic({
|
|
9724
9917
|
name: "unnecessaryPipe",
|
|
9725
9918
|
code: 9,
|
|
9919
|
+
description: "Removes pipe calls with no arguments",
|
|
9726
9920
|
severity: "suggestion",
|
|
9727
9921
|
apply: fn("unnecessaryPipe.apply")(function* (sourceFile, report) {
|
|
9728
9922
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9768,6 +9962,7 @@ var unnecessaryPipe = createDiagnostic({
|
|
|
9768
9962
|
var unnecessaryPipeChain = createDiagnostic({
|
|
9769
9963
|
name: "unnecessaryPipeChain",
|
|
9770
9964
|
code: 16,
|
|
9965
|
+
description: "Simplifies chained pipe calls into a single pipe call",
|
|
9771
9966
|
severity: "suggestion",
|
|
9772
9967
|
apply: fn("unnecessaryPipeChain.apply")(function* (sourceFile, report) {
|
|
9773
9968
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9842,6 +10037,7 @@ var unnecessaryPipeChain = createDiagnostic({
|
|
|
9842
10037
|
var unsupportedServiceAccessors = createDiagnostic({
|
|
9843
10038
|
name: "unsupportedServiceAccessors",
|
|
9844
10039
|
code: 21,
|
|
10040
|
+
description: "Warns about service accessors that need codegen due to generic/complex signatures",
|
|
9845
10041
|
severity: "warning",
|
|
9846
10042
|
apply: fn("unsupportedServiceAccessors.apply")(function* (sourceFile, report) {
|
|
9847
10043
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -9929,7 +10125,8 @@ var diagnostics = [
|
|
|
9929
10125
|
unknownInEffectCatch,
|
|
9930
10126
|
runEffectInsideEffect,
|
|
9931
10127
|
schemaUnionOfLiterals,
|
|
9932
|
-
schemaStructWithTag
|
|
10128
|
+
schemaStructWithTag,
|
|
10129
|
+
globalErrorInEffectFailure
|
|
9933
10130
|
];
|
|
9934
10131
|
|
|
9935
10132
|
// src/completions/effectDiagnosticsComment.ts
|
|
@@ -10126,6 +10323,43 @@ var effectSelfInClasses = createCompletion({
|
|
|
10126
10323
|
})
|
|
10127
10324
|
});
|
|
10128
10325
|
|
|
10326
|
+
// src/completions/effectSqlModelSelfInClasses.ts
|
|
10327
|
+
var effectSqlModelSelfInClasses = createCompletion({
|
|
10328
|
+
name: "effectSqlModelSelfInClasses",
|
|
10329
|
+
apply: fn("effectSqlModelSelfInClasses")(function* (sourceFile, position) {
|
|
10330
|
+
const ts = yield* service(TypeScriptApi);
|
|
10331
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
10332
|
+
const typeParser = yield* service(TypeParser);
|
|
10333
|
+
const maybeInfos = tsUtils.parseDataForExtendsClassCompletion(sourceFile, position);
|
|
10334
|
+
if (!maybeInfos) return [];
|
|
10335
|
+
const { accessedObject, className, replacementSpan } = maybeInfos;
|
|
10336
|
+
const schemaIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
10337
|
+
sourceFile,
|
|
10338
|
+
"@effect/sql",
|
|
10339
|
+
"Model"
|
|
10340
|
+
) || "Model";
|
|
10341
|
+
const isFullyQualified = schemaIdentifier === ts.idText(accessedObject);
|
|
10342
|
+
const name = ts.idText(className);
|
|
10343
|
+
const completions2 = [];
|
|
10344
|
+
const hasClassCompletion = isFullyQualified || isSome2(
|
|
10345
|
+
yield* pipe(
|
|
10346
|
+
typeParser.isNodeReferenceToEffectSqlModelModuleApi("Class")(accessedObject),
|
|
10347
|
+
option
|
|
10348
|
+
)
|
|
10349
|
+
);
|
|
10350
|
+
if (hasClassCompletion) {
|
|
10351
|
+
completions2.push({
|
|
10352
|
+
name: `Class<${name}>`,
|
|
10353
|
+
kind: ts.ScriptElementKind.constElement,
|
|
10354
|
+
insertText: isFullyQualified ? `${schemaIdentifier}.Class<${name}>("${name}")({${"${0}"}}){}` : `Class<${name}>("${name}")({${"${0}"}}){}`,
|
|
10355
|
+
replacementSpan,
|
|
10356
|
+
isSnippet: true
|
|
10357
|
+
});
|
|
10358
|
+
}
|
|
10359
|
+
return completions2;
|
|
10360
|
+
})
|
|
10361
|
+
});
|
|
10362
|
+
|
|
10129
10363
|
// src/completions/fnFunctionStar.ts
|
|
10130
10364
|
var fnFunctionStar = createCompletion({
|
|
10131
10365
|
name: "fnFunctionStar",
|
|
@@ -10182,10 +10416,12 @@ var genFunctionStar = createCompletion({
|
|
|
10182
10416
|
const ts = yield* service(TypeScriptApi);
|
|
10183
10417
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
10184
10418
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
10419
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
10185
10420
|
const maybeInfos = tsUtils.parseAccessedExpressionForCompletion(sourceFile, position);
|
|
10186
10421
|
if (!maybeInfos) return [];
|
|
10187
10422
|
const { accessedObject } = maybeInfos;
|
|
10188
|
-
const type =
|
|
10423
|
+
const type = typeCheckerUtils.getTypeAtLocation(accessedObject);
|
|
10424
|
+
if (!type) return [];
|
|
10189
10425
|
const genMemberSymbol = type.getProperty("gen");
|
|
10190
10426
|
if (!genMemberSymbol) return [];
|
|
10191
10427
|
const genType = typeChecker.getTypeOfSymbolAtLocation(genMemberSymbol, accessedObject);
|
|
@@ -10272,6 +10508,7 @@ var schemaBrand = createCompletion({
|
|
|
10272
10508
|
|
|
10273
10509
|
// src/completions.ts
|
|
10274
10510
|
var completions = [
|
|
10511
|
+
effectSqlModelSelfInClasses,
|
|
10275
10512
|
effectSchemaSelfInClasses,
|
|
10276
10513
|
effectSelfInClasses,
|
|
10277
10514
|
contextSelfInClasses,
|
|
@@ -10907,6 +11144,7 @@ function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
|
|
|
10907
11144
|
const ts = yield* service(TypeScriptApi);
|
|
10908
11145
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
10909
11146
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
11147
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
10910
11148
|
const textRange = tsUtils.toTextRange(position);
|
|
10911
11149
|
function isSymbolFromEffectRpcModule(symbol3) {
|
|
10912
11150
|
if (symbol3.valueDeclaration) {
|
|
@@ -10938,7 +11176,8 @@ function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
|
|
|
10938
11176
|
let callNode = null;
|
|
10939
11177
|
for (const node of tsUtils.getAncestorNodesInRange(sourceFile, textRange)) {
|
|
10940
11178
|
if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && tsUtils.isNodeInRange(textRange)(node.name)) {
|
|
10941
|
-
const type =
|
|
11179
|
+
const type = typeCheckerUtils.getTypeAtLocation(node);
|
|
11180
|
+
if (!type) return void 0;
|
|
10942
11181
|
for (const callSig of typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call)) {
|
|
10943
11182
|
if (callSig.parameters.length >= 2 && isSymbolFromEffectRpcClientModule(callSig.parameters[1])) {
|
|
10944
11183
|
rpcName = ts.idText(node.name);
|
|
@@ -10972,11 +11211,13 @@ function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
|
|
|
10972
11211
|
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && (ts.idText(node.expression.name) === "make" || ts.idText(node.expression.name) === "fromTaggedRequest")) {
|
|
10973
11212
|
const symbol3 = typeChecker.getSymbolAtLocation(node.expression.name);
|
|
10974
11213
|
if (symbol3 && isSymbolFromEffectRpcModule(symbol3)) {
|
|
10975
|
-
const type =
|
|
10976
|
-
|
|
10977
|
-
|
|
10978
|
-
|
|
10979
|
-
|
|
11214
|
+
const type = typeCheckerUtils.getTypeAtLocation(node);
|
|
11215
|
+
if (type) {
|
|
11216
|
+
const _tag = type.getProperty("_tag");
|
|
11217
|
+
if (_tag) {
|
|
11218
|
+
const tagValue = typeChecker.getTypeOfSymbolAtLocation(_tag, node);
|
|
11219
|
+
if ("value" in tagValue && tagValue.value === rpcName) result.push([node, symbol3]);
|
|
11220
|
+
}
|
|
10980
11221
|
}
|
|
10981
11222
|
}
|
|
10982
11223
|
}
|
|
@@ -11070,6 +11311,7 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
11070
11311
|
gen(function* () {
|
|
11071
11312
|
const ts = yield* service(TypeScriptApi);
|
|
11072
11313
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
11314
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
11073
11315
|
const typeParser = yield* service(TypeParser);
|
|
11074
11316
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
11075
11317
|
const options = yield* service(LanguageServicePluginOptions);
|
|
@@ -11185,13 +11427,16 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
11185
11427
|
const adjustedNode = getNodeForQuickInfo(touchingNode);
|
|
11186
11428
|
if (ts.isToken(adjustedNode) && adjustedNode.kind === ts.SyntaxKind.YieldKeyword) {
|
|
11187
11429
|
if (ts.isYieldExpression(adjustedNode.parent) && adjustedNode.parent.asteriskToken && adjustedNode.parent.expression) {
|
|
11188
|
-
|
|
11189
|
-
|
|
11190
|
-
|
|
11191
|
-
|
|
11192
|
-
|
|
11193
|
-
|
|
11194
|
-
|
|
11430
|
+
const type3 = typeCheckerUtils.getTypeAtLocation(adjustedNode.parent.expression);
|
|
11431
|
+
if (type3) {
|
|
11432
|
+
return {
|
|
11433
|
+
label: "Effect Type Parameters",
|
|
11434
|
+
type: type3,
|
|
11435
|
+
atLocation: adjustedNode.parent.expression,
|
|
11436
|
+
node: adjustedNode.parent,
|
|
11437
|
+
shouldTry: true
|
|
11438
|
+
};
|
|
11439
|
+
}
|
|
11195
11440
|
}
|
|
11196
11441
|
}
|
|
11197
11442
|
const nodeSignature = getSignatureForQuickInfo(adjustedNode);
|
|
@@ -11204,13 +11449,16 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
11204
11449
|
shouldTry: options.quickinfoEffectParameters === "always" && quickInfo2 ? true : quickInfo2 && ts.displayPartsToString(quickInfo2.displayParts).indexOf("...") > -1
|
|
11205
11450
|
};
|
|
11206
11451
|
}
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
|
|
11212
|
-
|
|
11213
|
-
|
|
11452
|
+
const type2 = typeCheckerUtils.getTypeAtLocation(adjustedNode);
|
|
11453
|
+
if (type2) {
|
|
11454
|
+
return {
|
|
11455
|
+
label: "Effect Type Parameters",
|
|
11456
|
+
type: type2,
|
|
11457
|
+
atLocation: adjustedNode,
|
|
11458
|
+
node: adjustedNode,
|
|
11459
|
+
shouldTry: options.quickinfoEffectParameters === "always" && quickInfo2 ? true : quickInfo2 && ts.displayPartsToString(quickInfo2.displayParts).indexOf("...") > -1
|
|
11460
|
+
};
|
|
11461
|
+
}
|
|
11214
11462
|
}
|
|
11215
11463
|
const data = getDataForQuickInfo();
|
|
11216
11464
|
if (!(data && data.shouldTry)) return quickInfo2;
|
|
@@ -15479,7 +15727,7 @@ var extractLayerGraph = fn("extractLayerGraph")(function* (node, opts) {
|
|
|
15479
15727
|
}
|
|
15480
15728
|
}
|
|
15481
15729
|
} else if (ts.isExpression(node2)) {
|
|
15482
|
-
layerType =
|
|
15730
|
+
layerType = typeCheckerUtils.getTypeAtLocation(node2);
|
|
15483
15731
|
}
|
|
15484
15732
|
if (layerType) {
|
|
15485
15733
|
layerTypes = yield* pipe(typeParser.layerType(layerType, node2), orElse2(() => void_));
|
|
@@ -15995,7 +16243,7 @@ function getAdjustedNode(sourceFile, position) {
|
|
|
15995
16243
|
return gen(function* () {
|
|
15996
16244
|
const ts = yield* service(TypeScriptApi);
|
|
15997
16245
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
15998
|
-
const
|
|
16246
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
15999
16247
|
const typeParser = yield* service(TypeParser);
|
|
16000
16248
|
const range = tsUtils.toTextRange(position);
|
|
16001
16249
|
const maybeNode = pipe(
|
|
@@ -16007,10 +16255,12 @@ function getAdjustedNode(sourceFile, position) {
|
|
|
16007
16255
|
if (isNone2(maybeNode)) return void 0;
|
|
16008
16256
|
const node = maybeNode.value;
|
|
16009
16257
|
const layerNode = node.initializer ? node.initializer : node;
|
|
16010
|
-
const layerType =
|
|
16011
|
-
|
|
16012
|
-
|
|
16013
|
-
|
|
16258
|
+
const layerType = typeCheckerUtils.getTypeAtLocation(layerNode);
|
|
16259
|
+
if (layerType) {
|
|
16260
|
+
const maybeLayer = yield* option(typeParser.layerType(layerType, layerNode));
|
|
16261
|
+
if (isNone2(maybeLayer)) return void 0;
|
|
16262
|
+
return { node, layerNode };
|
|
16263
|
+
}
|
|
16014
16264
|
});
|
|
16015
16265
|
}
|
|
16016
16266
|
function parseLayerGraph(layerNode) {
|
|
@@ -17645,15 +17895,21 @@ var processNode = (node, isVirtualTypeNode) => gen(function* () {
|
|
|
17645
17895
|
}
|
|
17646
17896
|
if (ts.isTypeQueryNode(node)) {
|
|
17647
17897
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
17648
|
-
const
|
|
17649
|
-
const
|
|
17650
|
-
if (
|
|
17898
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
17899
|
+
const type = typeCheckerUtils.getTypeAtLocation(node.exprName);
|
|
17900
|
+
if (type) {
|
|
17901
|
+
const typeNode = typeChecker.typeToTypeNode(type, void 0, ts.NodeBuilderFlags.NoTruncation);
|
|
17902
|
+
if (typeNode) return yield* processNode(typeNode, true);
|
|
17903
|
+
}
|
|
17651
17904
|
}
|
|
17652
17905
|
if (!isVirtualTypeNode && ts.isIndexedAccessTypeNode(node) && ts.isParenthesizedTypeNode(node.objectType) && ts.isTypeQueryNode(node.objectType.type) && ts.isTypeOperatorNode(node.indexType) && node.indexType.operator === ts.SyntaxKind.KeyOfKeyword && ts.isTypeQueryNode(node.indexType.type) && node.indexType.type.exprName.getText().trim() === node.objectType.type.exprName.getText().trim()) {
|
|
17653
17906
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
17654
|
-
const
|
|
17655
|
-
const
|
|
17656
|
-
if (
|
|
17907
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
17908
|
+
const type = typeCheckerUtils.getTypeAtLocation(node);
|
|
17909
|
+
if (type) {
|
|
17910
|
+
const typeNode = typeChecker.typeToTypeNode(type, void 0, ts.NodeBuilderFlags.NoTruncation);
|
|
17911
|
+
if (typeNode) return yield* processNode(typeNode, true);
|
|
17912
|
+
}
|
|
17657
17913
|
}
|
|
17658
17914
|
if (ts.isTypeReferenceNode(node)) {
|
|
17659
17915
|
const parsedName = entityNameToDataTypeName(node.typeName);
|
|
@@ -17960,6 +18216,7 @@ var wrapWithEffectGen = createRefactor({
|
|
|
17960
18216
|
const ts = yield* service(TypeScriptApi);
|
|
17961
18217
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
17962
18218
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
18219
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
17963
18220
|
const typeParser = yield* service(TypeParser);
|
|
17964
18221
|
const findEffectToWrap = fn("wrapWithEffectGen.apply.findEffectToWrap")(
|
|
17965
18222
|
function* (node) {
|
|
@@ -17967,7 +18224,8 @@ var wrapWithEffectGen = createRefactor({
|
|
|
17967
18224
|
if (node.parent && ts.isHeritageClause(node.parent)) return yield* fail3("is in a heritage clause");
|
|
17968
18225
|
const parent = node.parent;
|
|
17969
18226
|
if (parent != null && ts.isVariableDeclaration(parent) && parent.initializer !== node) return yield* fail3("is LHS of variable declaration");
|
|
17970
|
-
const type =
|
|
18227
|
+
const type = typeCheckerUtils.getTypeAtLocation(node);
|
|
18228
|
+
if (!type) return yield* fail3("cannot get type");
|
|
17971
18229
|
yield* typeParser.strictEffectType(type, node);
|
|
17972
18230
|
return node;
|
|
17973
18231
|
}
|