@effect/language-service 0.35.1 → 0.36.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 +42 -2
- package/cli.js +1501 -4371
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +5108 -0
- package/effect-lsp-patch-utils.js.map +1 -0
- package/index.js +387 -294
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +332 -263
- 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.17.
|
|
3
|
+
// node_modules/.pnpm/effect@3.17.8/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") {
|
|
@@ -96,7 +96,7 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
// node_modules/.pnpm/effect@3.17.
|
|
99
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Equivalence.js
|
|
100
100
|
var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
|
|
101
101
|
var array = (item) => make((self, that) => {
|
|
102
102
|
if (self.length !== that.length) {
|
|
@@ -111,7 +111,7 @@ var array = (item) => make((self, that) => {
|
|
|
111
111
|
return true;
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
// node_modules/.pnpm/effect@3.17.
|
|
114
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/GlobalValue.js
|
|
115
115
|
var globalStoreId = `effect/GlobalValue`;
|
|
116
116
|
var globalStore;
|
|
117
117
|
var globalValue = (id, compute) => {
|
|
@@ -125,7 +125,7 @@ var globalValue = (id, compute) => {
|
|
|
125
125
|
return globalStore.get(id);
|
|
126
126
|
};
|
|
127
127
|
|
|
128
|
-
// node_modules/.pnpm/effect@3.17.
|
|
128
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Predicate.js
|
|
129
129
|
var isString = (input) => typeof input === "string";
|
|
130
130
|
var isNumber = (input) => typeof input === "number";
|
|
131
131
|
var isBoolean = (input) => typeof input === "boolean";
|
|
@@ -135,7 +135,7 @@ var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
|
|
|
135
135
|
var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
|
|
136
136
|
var isRecord = (input) => isRecordOrArray(input) && !Array.isArray(input);
|
|
137
137
|
|
|
138
|
-
// node_modules/.pnpm/effect@3.17.
|
|
138
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Utils.js
|
|
139
139
|
var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
|
|
140
140
|
var GenKindImpl = class {
|
|
141
141
|
value;
|
|
@@ -257,7 +257,7 @@ var internalCall = isNotOptimizedAway ? standard.effect_internal_function : forc
|
|
|
257
257
|
var genConstructor = function* () {
|
|
258
258
|
}.constructor;
|
|
259
259
|
|
|
260
|
-
// node_modules/.pnpm/effect@3.17.
|
|
260
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Hash.js
|
|
261
261
|
var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
|
|
262
262
|
var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
|
|
263
263
|
var hash = (self) => {
|
|
@@ -356,7 +356,7 @@ var cached = function() {
|
|
|
356
356
|
return hash2;
|
|
357
357
|
};
|
|
358
358
|
|
|
359
|
-
// node_modules/.pnpm/effect@3.17.
|
|
359
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Equal.js
|
|
360
360
|
var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
|
|
361
361
|
function equals() {
|
|
362
362
|
if (arguments.length === 1) {
|
|
@@ -410,7 +410,7 @@ function compareBoth(self, that) {
|
|
|
410
410
|
var isEqual = (u) => hasProperty(u, symbol2);
|
|
411
411
|
var equivalence = () => equals;
|
|
412
412
|
|
|
413
|
-
// node_modules/.pnpm/effect@3.17.
|
|
413
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Inspectable.js
|
|
414
414
|
var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
415
415
|
var toJSON = (x) => {
|
|
416
416
|
try {
|
|
@@ -462,7 +462,7 @@ var redact = (u) => {
|
|
|
462
462
|
return u;
|
|
463
463
|
};
|
|
464
464
|
|
|
465
|
-
// node_modules/.pnpm/effect@3.17.
|
|
465
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Pipeable.js
|
|
466
466
|
var pipeArguments = (self, args2) => {
|
|
467
467
|
switch (args2.length) {
|
|
468
468
|
case 0:
|
|
@@ -495,14 +495,14 @@ var pipeArguments = (self, args2) => {
|
|
|
495
495
|
}
|
|
496
496
|
};
|
|
497
497
|
|
|
498
|
-
// node_modules/.pnpm/effect@3.17.
|
|
498
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/opCodes/effect.js
|
|
499
499
|
var OP_COMMIT = "Commit";
|
|
500
500
|
|
|
501
|
-
// node_modules/.pnpm/effect@3.17.
|
|
502
|
-
var moduleVersion = "3.17.
|
|
501
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/version.js
|
|
502
|
+
var moduleVersion = "3.17.8";
|
|
503
503
|
var getCurrentVersion = () => moduleVersion;
|
|
504
504
|
|
|
505
|
-
// node_modules/.pnpm/effect@3.17.
|
|
505
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/effectable.js
|
|
506
506
|
var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
|
|
507
507
|
var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
|
|
508
508
|
var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
|
|
@@ -589,7 +589,7 @@ var StructuralCommitPrototype = {
|
|
|
589
589
|
...StructuralPrototype
|
|
590
590
|
};
|
|
591
591
|
|
|
592
|
-
// node_modules/.pnpm/effect@3.17.
|
|
592
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/option.js
|
|
593
593
|
var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
|
|
594
594
|
var CommonProto = {
|
|
595
595
|
...EffectPrototype,
|
|
@@ -647,7 +647,7 @@ var some = (value) => {
|
|
|
647
647
|
return a;
|
|
648
648
|
};
|
|
649
649
|
|
|
650
|
-
// node_modules/.pnpm/effect@3.17.
|
|
650
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/either.js
|
|
651
651
|
var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
|
|
652
652
|
var CommonProto2 = {
|
|
653
653
|
...EffectPrototype,
|
|
@@ -709,7 +709,7 @@ var right = (right3) => {
|
|
|
709
709
|
return a;
|
|
710
710
|
};
|
|
711
711
|
|
|
712
|
-
// node_modules/.pnpm/effect@3.17.
|
|
712
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Either.js
|
|
713
713
|
var right2 = right;
|
|
714
714
|
var left2 = left;
|
|
715
715
|
var isLeft2 = isLeft;
|
|
@@ -717,11 +717,11 @@ var isRight2 = isRight;
|
|
|
717
717
|
var map = /* @__PURE__ */ dual(2, (self, f) => isRight2(self) ? right2(f(self.right)) : left2(self.left));
|
|
718
718
|
var getOrElse = /* @__PURE__ */ dual(2, (self, onLeft) => isLeft2(self) ? onLeft(self.left) : self.right);
|
|
719
719
|
|
|
720
|
-
// node_modules/.pnpm/effect@3.17.
|
|
720
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Order.js
|
|
721
721
|
var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that);
|
|
722
722
|
var string2 = /* @__PURE__ */ make2((self, that) => self < that ? -1 : 1);
|
|
723
723
|
|
|
724
|
-
// node_modules/.pnpm/effect@3.17.
|
|
724
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Option.js
|
|
725
725
|
var none2 = () => none;
|
|
726
726
|
var some2 = some;
|
|
727
727
|
var isNone2 = isNone;
|
|
@@ -1036,10 +1036,10 @@ var TypeScriptApi = Tag("TypeScriptApi");
|
|
|
1036
1036
|
var TypeScriptProgram = Tag("TypeScriptProgram");
|
|
1037
1037
|
var ChangeTracker = Tag("ChangeTracker");
|
|
1038
1038
|
|
|
1039
|
-
// node_modules/.pnpm/effect@3.17.
|
|
1039
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/array.js
|
|
1040
1040
|
var isNonEmptyArray = (self) => self.length > 0;
|
|
1041
1041
|
|
|
1042
|
-
// node_modules/.pnpm/effect@3.17.
|
|
1042
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Array.js
|
|
1043
1043
|
var fromIterable = (collection) => Array.isArray(collection) ? collection : Array.from(collection);
|
|
1044
1044
|
var append = /* @__PURE__ */ dual(2, (self, last) => [...self, last]);
|
|
1045
1045
|
var appendAll = /* @__PURE__ */ dual(2, (self, that) => fromIterable(self).concat(fromIterable(that)));
|
|
@@ -1203,7 +1203,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1203
1203
|
const sourceText = sourceFile.text;
|
|
1204
1204
|
let result;
|
|
1205
1205
|
function find(node) {
|
|
1206
|
-
const leading = ts.getLeadingCommentRanges(sourceText, node.
|
|
1206
|
+
const leading = ts.getLeadingCommentRanges(sourceText, node.pos);
|
|
1207
1207
|
if (leading) {
|
|
1208
1208
|
for (const commentRange of leading) {
|
|
1209
1209
|
if (commentRange.pos <= position && position < commentRange.end) {
|
|
@@ -1212,8 +1212,8 @@ function makeTypeScriptUtils(ts) {
|
|
|
1212
1212
|
}
|
|
1213
1213
|
}
|
|
1214
1214
|
}
|
|
1215
|
-
if (node.
|
|
1216
|
-
|
|
1215
|
+
if (node.pos <= position && position < node.end) {
|
|
1216
|
+
ts.forEachChild(node, find);
|
|
1217
1217
|
}
|
|
1218
1218
|
}
|
|
1219
1219
|
find(sourceFile);
|
|
@@ -1232,7 +1232,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1232
1232
|
}
|
|
1233
1233
|
function findNodeAtPosition(sourceFile, position) {
|
|
1234
1234
|
function find(node) {
|
|
1235
|
-
if (position >=
|
|
1235
|
+
if (position >= ts.getTokenPosOfNode(node, sourceFile) && position < node.end) {
|
|
1236
1236
|
return ts.forEachChild(node, find) || node;
|
|
1237
1237
|
}
|
|
1238
1238
|
return void 0;
|
|
@@ -1259,7 +1259,6 @@ function makeTypeScriptUtils(ts) {
|
|
|
1259
1259
|
return;
|
|
1260
1260
|
}
|
|
1261
1261
|
const startPos = token.pos === 0 ? (ts.getShebang(sourceFile.text) || "").length : token.pos;
|
|
1262
|
-
if (startPos === 0) return;
|
|
1263
1262
|
const result = ts.forEachTrailingCommentRange(sourceFile.text, startPos, isCommentInRange, pos) || ts.forEachLeadingCommentRange(sourceFile.text, startPos, isCommentInRange, pos);
|
|
1264
1263
|
return result;
|
|
1265
1264
|
}
|
|
@@ -1464,23 +1463,26 @@ function makeTypeScriptUtils(ts) {
|
|
|
1464
1463
|
let replacementSpan = ts.createTextSpan(position, 0);
|
|
1465
1464
|
let outerNode = precedingToken;
|
|
1466
1465
|
if (ts.isIdentifier(precedingToken) && precedingToken.parent && ts.isPropertyAccessExpression(precedingToken.parent)) {
|
|
1466
|
+
const spanStart = ts.getTokenPosOfNode(precedingToken.parent, sourceFile);
|
|
1467
1467
|
replacementSpan = ts.createTextSpan(
|
|
1468
|
-
|
|
1469
|
-
precedingToken.end -
|
|
1468
|
+
spanStart,
|
|
1469
|
+
precedingToken.end - spanStart
|
|
1470
1470
|
);
|
|
1471
1471
|
accessedObject = precedingToken.parent.expression;
|
|
1472
1472
|
outerNode = precedingToken.parent;
|
|
1473
1473
|
} else if (ts.isToken(precedingToken) && precedingToken.kind === ts.SyntaxKind.DotToken && ts.isPropertyAccessExpression(precedingToken.parent)) {
|
|
1474
|
+
const precedingTokenSpanStart = ts.getTokenPosOfNode(precedingToken.parent, sourceFile);
|
|
1474
1475
|
replacementSpan = ts.createTextSpan(
|
|
1475
|
-
|
|
1476
|
-
precedingToken.end -
|
|
1476
|
+
precedingTokenSpanStart,
|
|
1477
|
+
precedingToken.end - precedingTokenSpanStart
|
|
1477
1478
|
);
|
|
1478
1479
|
accessedObject = precedingToken.parent.expression;
|
|
1479
1480
|
outerNode = precedingToken.parent;
|
|
1480
1481
|
} else if (ts.isIdentifier(precedingToken) && precedingToken.parent) {
|
|
1482
|
+
const precedingTokenSpanStart = ts.getTokenPosOfNode(precedingToken, sourceFile);
|
|
1481
1483
|
replacementSpan = ts.createTextSpan(
|
|
1482
|
-
|
|
1483
|
-
precedingToken.end -
|
|
1484
|
+
precedingTokenSpanStart,
|
|
1485
|
+
precedingToken.end - precedingTokenSpanStart
|
|
1484
1486
|
);
|
|
1485
1487
|
accessedObject = precedingToken;
|
|
1486
1488
|
outerNode = precedingToken;
|
|
@@ -1574,6 +1576,13 @@ function makeTypeScriptUtils(ts) {
|
|
|
1574
1576
|
[]
|
|
1575
1577
|
);
|
|
1576
1578
|
}
|
|
1579
|
+
function getSourceFileOfNode(current) {
|
|
1580
|
+
let node = current;
|
|
1581
|
+
while (node && node.kind !== ts.SyntaxKind.SourceFile) {
|
|
1582
|
+
node = node.parent;
|
|
1583
|
+
}
|
|
1584
|
+
return node;
|
|
1585
|
+
}
|
|
1577
1586
|
return {
|
|
1578
1587
|
findNodeAtPositionIncludingTrivia,
|
|
1579
1588
|
parsePackageContentNameAndVersionFromScope,
|
|
@@ -1593,7 +1602,8 @@ function makeTypeScriptUtils(ts) {
|
|
|
1593
1602
|
createEffectGenCallExpressionWithBlock,
|
|
1594
1603
|
createReturnYieldStarStatement,
|
|
1595
1604
|
makeGetModuleSpecifier,
|
|
1596
|
-
parseAccessedExpressionForCompletion
|
|
1605
|
+
parseAccessedExpressionForCompletion,
|
|
1606
|
+
getSourceFileOfNode
|
|
1597
1607
|
};
|
|
1598
1608
|
}
|
|
1599
1609
|
|
|
@@ -1653,6 +1663,18 @@ function createRefactor(definition) {
|
|
|
1653
1663
|
function createDiagnostic(definition) {
|
|
1654
1664
|
return definition;
|
|
1655
1665
|
}
|
|
1666
|
+
function concatDiagnostics(fa, fb) {
|
|
1667
|
+
const result = fa.slice(0);
|
|
1668
|
+
for (const b of fb) {
|
|
1669
|
+
const existing = result.find(
|
|
1670
|
+
(a) => a.file === b.file && a.code === b.code && a.source === b.source && a.start === b.start && a.length === b.length && a.messageText === b.messageText
|
|
1671
|
+
);
|
|
1672
|
+
if (!existing) {
|
|
1673
|
+
result.push(b);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
return result;
|
|
1677
|
+
}
|
|
1656
1678
|
function createCompletion(definition) {
|
|
1657
1679
|
return definition;
|
|
1658
1680
|
}
|
|
@@ -1753,7 +1775,7 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1753
1775
|
if (foundNode) {
|
|
1754
1776
|
lineOverrides[ruleName] = lineOverrides[ruleName] || [];
|
|
1755
1777
|
lineOverrides[ruleName].unshift({
|
|
1756
|
-
pos: foundNode.node.
|
|
1778
|
+
pos: foundNode.node.pos,
|
|
1757
1779
|
end: foundNode.node.end,
|
|
1758
1780
|
level: ruleLevel
|
|
1759
1781
|
});
|
|
@@ -1792,11 +1814,12 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1792
1814
|
service(ChangeTracker),
|
|
1793
1815
|
(changeTracker) => gen(function* () {
|
|
1794
1816
|
const disableAtNode = findParentStatementForDisableNextLine(node);
|
|
1795
|
-
const
|
|
1817
|
+
const start = ts.getTokenPosOfNode(disableAtNode, sourceFile);
|
|
1818
|
+
const { line } = ts.getLineAndCharacterOfPosition(sourceFile, start);
|
|
1796
1819
|
changeTracker.insertCommentBeforeLine(
|
|
1797
1820
|
sourceFile,
|
|
1798
1821
|
line,
|
|
1799
|
-
|
|
1822
|
+
start,
|
|
1800
1823
|
` @effect-diagnostics-next-line ${rule.name}:off`
|
|
1801
1824
|
);
|
|
1802
1825
|
})
|
|
@@ -1819,8 +1842,8 @@ var createDiagnosticExecutor = fn("LSP.createCommentDirectivesProcessor")(
|
|
|
1819
1842
|
};
|
|
1820
1843
|
const applicableDiagnostics = [];
|
|
1821
1844
|
yield* rule.apply(sourceFile, (entry) => {
|
|
1822
|
-
const range = "
|
|
1823
|
-
const node = "
|
|
1845
|
+
const range = "kind" in entry.location ? { pos: ts.getTokenPosOfNode(entry.location, sourceFile), end: entry.location.end } : entry.location;
|
|
1846
|
+
const node = "kind" in entry.location ? entry.location : tsUtils.findNodeAtPositionIncludingTrivia(sourceFile, entry.location.pos);
|
|
1824
1847
|
applicableDiagnostics.push({
|
|
1825
1848
|
range,
|
|
1826
1849
|
messageText: entry.messageText,
|
|
@@ -1953,8 +1976,8 @@ var contextSelfInClasses = createCompletion({
|
|
|
1953
1976
|
"effect",
|
|
1954
1977
|
"Context"
|
|
1955
1978
|
) || "Context";
|
|
1956
|
-
if (contextIdentifier !== accessedObject
|
|
1957
|
-
const name = className
|
|
1979
|
+
if (contextIdentifier !== ts.idText(accessedObject)) return [];
|
|
1980
|
+
const name = ts.idText(className);
|
|
1958
1981
|
return [{
|
|
1959
1982
|
name: `Tag("${name}")`,
|
|
1960
1983
|
kind: ts.ScriptElementKind.constElement,
|
|
@@ -1977,29 +2000,6 @@ var deterministicTypeOrder = gen(function* () {
|
|
|
1977
2000
|
return 0;
|
|
1978
2001
|
});
|
|
1979
2002
|
});
|
|
1980
|
-
var getMissingTypeEntriesInTargetType = fn(
|
|
1981
|
-
"TypeCheckerApi.getMissingTypeEntriesInTargetType"
|
|
1982
|
-
)(
|
|
1983
|
-
function* (realType, expectedType) {
|
|
1984
|
-
if (realType === expectedType) return [];
|
|
1985
|
-
const typeChecker = yield* service(TypeCheckerApi);
|
|
1986
|
-
const result = [];
|
|
1987
|
-
let toTest = [realType];
|
|
1988
|
-
while (toTest.length > 0) {
|
|
1989
|
-
const type = toTest.pop();
|
|
1990
|
-
if (!type) return result;
|
|
1991
|
-
if (type.isUnion()) {
|
|
1992
|
-
toTest = toTest.concat(type.types);
|
|
1993
|
-
} else {
|
|
1994
|
-
const assignable = typeChecker.isTypeAssignableTo(type, expectedType);
|
|
1995
|
-
if (!assignable) {
|
|
1996
|
-
result.push(type);
|
|
1997
|
-
}
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
return result;
|
|
2001
|
-
}
|
|
2002
|
-
);
|
|
2003
2003
|
var CannotFindAncestorConvertibleDeclarationError = class {
|
|
2004
2004
|
constructor(node) {
|
|
2005
2005
|
this.node = node;
|
|
@@ -2033,6 +2033,7 @@ var CannotInferReturnType = class {
|
|
|
2033
2033
|
};
|
|
2034
2034
|
var getInferredReturnType = fn("TypeCheckerApi.getInferredReturnType")(function* (declaration) {
|
|
2035
2035
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
2036
|
+
const ts = yield* service(TypeScriptApi);
|
|
2036
2037
|
if (!declaration.body) {
|
|
2037
2038
|
return yield* fail(
|
|
2038
2039
|
new CannotInferReturnTypeFromEmptyBody(declaration)
|
|
@@ -2040,10 +2041,13 @@ var getInferredReturnType = fn("TypeCheckerApi.getInferredReturnType")(function*
|
|
|
2040
2041
|
}
|
|
2041
2042
|
let returnType;
|
|
2042
2043
|
if (typeChecker.isImplementationOfOverload(declaration)) {
|
|
2043
|
-
const signatures = typeChecker.
|
|
2044
|
+
const signatures = typeChecker.getSignaturesOfType(
|
|
2045
|
+
typeChecker.getTypeAtLocation(declaration),
|
|
2046
|
+
ts.SignatureKind.Call
|
|
2047
|
+
);
|
|
2044
2048
|
if (signatures.length > 1) {
|
|
2045
2049
|
returnType = typeChecker.getUnionType(
|
|
2046
|
-
signatures.map((s) =>
|
|
2050
|
+
signatures.map((s) => typeChecker.getReturnTypeOfSignature(s)).filter((_) => !!_)
|
|
2047
2051
|
);
|
|
2048
2052
|
}
|
|
2049
2053
|
}
|
|
@@ -2086,7 +2090,7 @@ var expectedAndRealType = cachedBy(
|
|
|
2086
2090
|
} else if (ts.isCallExpression(node)) {
|
|
2087
2091
|
const resolvedSignature = typeChecker.getResolvedSignature(node);
|
|
2088
2092
|
if (resolvedSignature) {
|
|
2089
|
-
resolvedSignature.
|
|
2093
|
+
resolvedSignature.parameters.map((parameter, index) => {
|
|
2090
2094
|
const expectedType = typeChecker.getTypeOfSymbolAtLocation(parameter, node);
|
|
2091
2095
|
const realType = typeChecker.getTypeAtLocation(node.arguments[index]);
|
|
2092
2096
|
result.push([
|
|
@@ -2105,11 +2109,14 @@ var expectedAndRealType = cachedBy(
|
|
|
2105
2109
|
if (ts.isObjectLiteralExpression(parent.parent) && parent.name === node) {
|
|
2106
2110
|
const type = typeChecker.getContextualType(parent.parent);
|
|
2107
2111
|
if (type) {
|
|
2108
|
-
const
|
|
2109
|
-
if (
|
|
2110
|
-
const
|
|
2111
|
-
|
|
2112
|
-
|
|
2112
|
+
const name = ts.isIdentifier(node) ? ts.idText(node) : ts.isStringLiteral(node) ? node.text : void 0;
|
|
2113
|
+
if (name) {
|
|
2114
|
+
const symbol3 = typeChecker.getPropertyOfType(type, name);
|
|
2115
|
+
if (symbol3) {
|
|
2116
|
+
const expectedType = typeChecker.getTypeOfSymbolAtLocation(symbol3, node);
|
|
2117
|
+
const realType = typeChecker.getTypeAtLocation(node);
|
|
2118
|
+
result.push([node, expectedType, node, realType]);
|
|
2119
|
+
}
|
|
2113
2120
|
}
|
|
2114
2121
|
}
|
|
2115
2122
|
}
|
|
@@ -2165,70 +2172,124 @@ var expectedAndRealType = cachedBy(
|
|
|
2165
2172
|
"TypeCheckerApi.expectedAndRealType",
|
|
2166
2173
|
(sourceFile) => sourceFile
|
|
2167
2174
|
);
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2175
|
+
function makeResolveExternalModuleName(typeChecker) {
|
|
2176
|
+
if (!(hasProperty(typeChecker, "resolveExternalModuleName") && isFunction(typeChecker.resolveExternalModuleName))) {
|
|
2177
|
+
return;
|
|
2178
|
+
}
|
|
2179
|
+
const _internal = typeChecker.resolveExternalModuleName;
|
|
2180
|
+
return (moduleSpecifier) => {
|
|
2181
|
+
return _internal(moduleSpecifier);
|
|
2182
|
+
};
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
// src/core/TypeCheckerUtils.ts
|
|
2186
|
+
var TypeCheckerUtils = Tag("TypeCheckerUtils");
|
|
2187
|
+
var nanoLayer2 = (fa) => pipe(
|
|
2188
|
+
service(TypeScriptApi),
|
|
2189
|
+
flatMap(
|
|
2190
|
+
(ts) => flatMap(service(TypeCheckerApi), (typeChecker) => pipe(fa, provideService(TypeCheckerUtils, makeTypeCheckerUtils(ts, typeChecker))))
|
|
2191
|
+
)
|
|
2192
|
+
);
|
|
2193
|
+
function makeTypeCheckerUtils(ts, typeChecker) {
|
|
2194
|
+
function isUnion(type) {
|
|
2195
|
+
return !!(type.flags & ts.TypeFlags.Union);
|
|
2196
|
+
}
|
|
2197
|
+
function isIndexType(type) {
|
|
2198
|
+
return !!(type.flags & ts.TypeFlags.Index);
|
|
2199
|
+
}
|
|
2200
|
+
function isThisTypeParameter(type) {
|
|
2201
|
+
return !!(type.flags & ts.TypeFlags.TypeParameter && type.isThisType);
|
|
2202
|
+
}
|
|
2203
|
+
function getTypeParameterAtPosition(signature, pos) {
|
|
2204
|
+
const type = typeChecker.getParameterType(signature, pos);
|
|
2205
|
+
if (isIndexType(type) && isThisTypeParameter(type.type)) {
|
|
2206
|
+
const constraint = typeChecker.getBaseConstraintOfType(type.type);
|
|
2207
|
+
if (constraint) {
|
|
2208
|
+
return typeChecker.getIndexType(constraint);
|
|
2209
|
+
}
|
|
2177
2210
|
}
|
|
2211
|
+
return type;
|
|
2178
2212
|
}
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
"TypeCheckerApi.appendToUniqueTypesMap"
|
|
2183
|
-
)(
|
|
2184
|
-
function* (memory, initialType, shouldExclude) {
|
|
2185
|
-
const typeChecker = yield* service(TypeCheckerApi);
|
|
2186
|
-
const newIndexes = /* @__PURE__ */ new Set();
|
|
2187
|
-
const knownIndexes = /* @__PURE__ */ new Set();
|
|
2188
|
-
let toTest = [initialType];
|
|
2213
|
+
const unrollUnionMembers = (type) => {
|
|
2214
|
+
const result = [];
|
|
2215
|
+
let toTest = [type];
|
|
2189
2216
|
while (toTest.length > 0) {
|
|
2190
|
-
const
|
|
2191
|
-
if (
|
|
2192
|
-
|
|
2193
|
-
|
|
2217
|
+
const type2 = toTest.pop();
|
|
2218
|
+
if (isUnion(type2)) {
|
|
2219
|
+
toTest = toTest.concat(type2.types);
|
|
2220
|
+
} else {
|
|
2221
|
+
result.push(type2);
|
|
2194
2222
|
}
|
|
2195
|
-
|
|
2223
|
+
}
|
|
2224
|
+
return result;
|
|
2225
|
+
};
|
|
2226
|
+
const getMissingTypeEntriesInTargetType = function(realType, expectedType) {
|
|
2227
|
+
if (realType === expectedType) return [];
|
|
2228
|
+
const result = [];
|
|
2229
|
+
let toTest = [realType];
|
|
2230
|
+
while (toTest.length > 0) {
|
|
2231
|
+
const type = toTest.pop();
|
|
2232
|
+
if (!type) return result;
|
|
2233
|
+
if (isUnion(type)) {
|
|
2196
2234
|
toTest = toTest.concat(type.types);
|
|
2197
2235
|
} else {
|
|
2198
|
-
const
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
if (areSame) {
|
|
2202
|
-
foundMatch.push(typeId);
|
|
2203
|
-
break;
|
|
2204
|
-
}
|
|
2236
|
+
const assignable = typeChecker.isTypeAssignableTo(type, expectedType);
|
|
2237
|
+
if (!assignable) {
|
|
2238
|
+
result.push(type);
|
|
2205
2239
|
}
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
return result;
|
|
2243
|
+
};
|
|
2244
|
+
const appendToUniqueTypesMap = fn(
|
|
2245
|
+
"TypeCheckerUtils.appendToUniqueTypesMap"
|
|
2246
|
+
)(
|
|
2247
|
+
function* (memory, initialType, shouldExclude) {
|
|
2248
|
+
const newIndexes = /* @__PURE__ */ new Set();
|
|
2249
|
+
const knownIndexes = /* @__PURE__ */ new Set();
|
|
2250
|
+
let toTest = [initialType];
|
|
2251
|
+
while (toTest.length > 0) {
|
|
2252
|
+
const type = toTest.pop();
|
|
2253
|
+
if (!type) break;
|
|
2254
|
+
if (yield* shouldExclude(type)) {
|
|
2255
|
+
continue;
|
|
2256
|
+
}
|
|
2257
|
+
if (isUnion(type)) {
|
|
2258
|
+
toTest = toTest.concat(type.types);
|
|
2210
2259
|
} else {
|
|
2211
|
-
|
|
2260
|
+
const foundMatch = [];
|
|
2261
|
+
for (const [typeId, knownType] of memory.entries()) {
|
|
2262
|
+
const areSame = typeChecker.isTypeAssignableTo(knownType, type) && typeChecker.isTypeAssignableTo(type, knownType);
|
|
2263
|
+
if (areSame) {
|
|
2264
|
+
foundMatch.push(typeId);
|
|
2265
|
+
break;
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
if (foundMatch.length === 0) {
|
|
2269
|
+
const newId = "t" + (memory.size + 1);
|
|
2270
|
+
memory.set(newId, type);
|
|
2271
|
+
newIndexes.add(newId);
|
|
2272
|
+
} else {
|
|
2273
|
+
knownIndexes.add(foundMatch[0]);
|
|
2274
|
+
}
|
|
2212
2275
|
}
|
|
2213
2276
|
}
|
|
2277
|
+
return {
|
|
2278
|
+
newIndexes,
|
|
2279
|
+
knownIndexes,
|
|
2280
|
+
allIndexes: pipe(
|
|
2281
|
+
fromIterable(newIndexes),
|
|
2282
|
+
appendAll(fromIterable(knownIndexes))
|
|
2283
|
+
)
|
|
2284
|
+
};
|
|
2214
2285
|
}
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
};
|
|
2223
|
-
}
|
|
2224
|
-
);
|
|
2225
|
-
function makeResolveExternalModuleName(typeChecker) {
|
|
2226
|
-
if (!(hasProperty(typeChecker, "resolveExternalModuleName") && isFunction(typeChecker.resolveExternalModuleName))) {
|
|
2227
|
-
return;
|
|
2228
|
-
}
|
|
2229
|
-
const _internal = typeChecker.resolveExternalModuleName;
|
|
2230
|
-
return (moduleSpecifier) => {
|
|
2231
|
-
return _internal(moduleSpecifier);
|
|
2286
|
+
);
|
|
2287
|
+
return {
|
|
2288
|
+
isUnion,
|
|
2289
|
+
getTypeParameterAtPosition,
|
|
2290
|
+
getMissingTypeEntriesInTargetType,
|
|
2291
|
+
unrollUnionMembers,
|
|
2292
|
+
appendToUniqueTypesMap
|
|
2232
2293
|
};
|
|
2233
2294
|
}
|
|
2234
2295
|
|
|
@@ -2238,11 +2299,12 @@ var durationInput = createCompletion({
|
|
|
2238
2299
|
apply: fn("durationInput")(function* (sourceFile, position) {
|
|
2239
2300
|
const ts = yield* service(TypeScriptApi);
|
|
2240
2301
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
2302
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
2241
2303
|
let isInString = false;
|
|
2242
2304
|
const previousToken = ts.findPrecedingToken(position, sourceFile);
|
|
2243
2305
|
if (previousToken && ts.isStringTextContainingNode(previousToken)) {
|
|
2244
|
-
const start =
|
|
2245
|
-
const end = previousToken.
|
|
2306
|
+
const start = ts.getTokenPosOfNode(previousToken, sourceFile);
|
|
2307
|
+
const end = previousToken.end;
|
|
2246
2308
|
if (start < position && position < end) {
|
|
2247
2309
|
isInString = true;
|
|
2248
2310
|
}
|
|
@@ -2252,7 +2314,7 @@ var durationInput = createCompletion({
|
|
|
2252
2314
|
if (isInString && ts.isExpression(previousToken)) {
|
|
2253
2315
|
const type = typeChecker.getContextualType(previousToken);
|
|
2254
2316
|
if (type) {
|
|
2255
|
-
if (!
|
|
2317
|
+
if (!typeCheckerUtils.isUnion(type)) return [];
|
|
2256
2318
|
for (const member of type.types) {
|
|
2257
2319
|
if (member.flags & ts.TypeFlags.TemplateLiteral) {
|
|
2258
2320
|
if (hasProperty(member, "texts") && isArray(member.texts) && member.texts.length === 2 && String(member.texts[1]).trim() === "nanos") {
|
|
@@ -2276,13 +2338,14 @@ var durationInput = createCompletion({
|
|
|
2276
2338
|
|
|
2277
2339
|
// src/core/TypeParser.ts
|
|
2278
2340
|
var TypeParser = Tag("@effect/language-service/TypeParser");
|
|
2279
|
-
var
|
|
2341
|
+
var nanoLayer3 = (fa) => gen(function* () {
|
|
2280
2342
|
const ts = yield* service(TypeScriptApi);
|
|
2281
2343
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
2282
2344
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
2345
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
2283
2346
|
return yield* pipe(
|
|
2284
2347
|
fa,
|
|
2285
|
-
provideService(TypeParser, make3(ts, tsUtils, typeChecker))
|
|
2348
|
+
provideService(TypeParser, make3(ts, tsUtils, typeChecker, typeCheckerUtils))
|
|
2286
2349
|
);
|
|
2287
2350
|
});
|
|
2288
2351
|
var TypeParserIssue = class _TypeParserIssue {
|
|
@@ -2292,27 +2355,27 @@ var TypeParserIssue = class _TypeParserIssue {
|
|
|
2292
2355
|
function typeParserIssue(_message, _type, _node) {
|
|
2293
2356
|
return TypeParserIssue.issue;
|
|
2294
2357
|
}
|
|
2295
|
-
function make3(ts, tsUtils, typeChecker) {
|
|
2358
|
+
function make3(ts, tsUtils, typeChecker, typeCheckerUtils) {
|
|
2296
2359
|
function covariantTypeArgument(type) {
|
|
2297
|
-
const signatures = type.
|
|
2360
|
+
const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
2298
2361
|
if (signatures.length !== 1) {
|
|
2299
2362
|
return typeParserIssue("Covariant type has no call signature", type);
|
|
2300
2363
|
}
|
|
2301
|
-
return succeed(signatures[0]
|
|
2364
|
+
return succeed(typeChecker.getReturnTypeOfSignature(signatures[0]));
|
|
2302
2365
|
}
|
|
2303
2366
|
function contravariantTypeArgument(type) {
|
|
2304
|
-
const signatures = type.
|
|
2367
|
+
const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
2305
2368
|
if (signatures.length !== 1) {
|
|
2306
2369
|
return typeParserIssue("Contravariant type has no call signature", type);
|
|
2307
2370
|
}
|
|
2308
|
-
return succeed(signatures[0]
|
|
2371
|
+
return succeed(typeCheckerUtils.getTypeParameterAtPosition(signatures[0], 0));
|
|
2309
2372
|
}
|
|
2310
2373
|
function invariantTypeArgument(type) {
|
|
2311
|
-
const signatures = type.
|
|
2374
|
+
const signatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
2312
2375
|
if (signatures.length !== 1) {
|
|
2313
2376
|
return typeParserIssue("Invariant type has no call signature", type);
|
|
2314
2377
|
}
|
|
2315
|
-
return succeed(signatures[0]
|
|
2378
|
+
return succeed(typeChecker.getReturnTypeOfSignature(signatures[0]));
|
|
2316
2379
|
}
|
|
2317
2380
|
const pipeableType = cachedBy(
|
|
2318
2381
|
function(type, atLocation) {
|
|
@@ -2321,7 +2384,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2321
2384
|
return typeParserIssue("Type has no 'pipe' property", type, atLocation);
|
|
2322
2385
|
}
|
|
2323
2386
|
const pipeType = typeChecker.getTypeOfSymbolAtLocation(pipeSymbol, atLocation);
|
|
2324
|
-
const signatures = pipeType.
|
|
2387
|
+
const signatures = typeChecker.getSignaturesOfType(pipeType, ts.SignatureKind.Call);
|
|
2325
2388
|
if (signatures.length === 0) {
|
|
2326
2389
|
return typeParserIssue("'pipe' property is not callable", type, atLocation);
|
|
2327
2390
|
}
|
|
@@ -2376,7 +2439,9 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2376
2439
|
const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
|
|
2377
2440
|
(_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration && ts.isPropertySignature(_.valueDeclaration) && ts.isComputedPropertyName(_.valueDeclaration.name)
|
|
2378
2441
|
);
|
|
2379
|
-
propertiesSymbols.sort(
|
|
2442
|
+
propertiesSymbols.sort(
|
|
2443
|
+
(a, b) => ts.symbolName(b).indexOf("EffectTypeId") - ts.symbolName(a).indexOf("EffectTypeId")
|
|
2444
|
+
);
|
|
2380
2445
|
for (const propertySymbol of propertiesSymbols) {
|
|
2381
2446
|
const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
|
|
2382
2447
|
result = pipe(result, orElse2(() => effectVarianceStruct(propertyType, atLocation)));
|
|
@@ -2388,7 +2453,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2388
2453
|
);
|
|
2389
2454
|
const strictEffectType = cachedBy(
|
|
2390
2455
|
fn("TypeParser.strictEffectType")(function* (type, atLocation) {
|
|
2391
|
-
if (!(type.symbol && type.symbol
|
|
2456
|
+
if (!(type.symbol && ts.symbolName(type.symbol) === "Effect" && !type.aliasSymbol)) {
|
|
2392
2457
|
return yield* typeParserIssue("Type name should be Effect with no alias symbol", type, atLocation);
|
|
2393
2458
|
}
|
|
2394
2459
|
return yield* effectType(type, atLocation);
|
|
@@ -2402,7 +2467,9 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2402
2467
|
const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
|
|
2403
2468
|
(_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration && ts.isPropertySignature(_.valueDeclaration) && ts.isComputedPropertyName(_.valueDeclaration.name)
|
|
2404
2469
|
);
|
|
2405
|
-
propertiesSymbols.sort(
|
|
2470
|
+
propertiesSymbols.sort(
|
|
2471
|
+
(a, b) => ts.symbolName(b).indexOf("LayerTypeId") - ts.symbolName(a).indexOf("LayerTypeId")
|
|
2472
|
+
);
|
|
2406
2473
|
for (const propertySymbol of propertiesSymbols) {
|
|
2407
2474
|
const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
|
|
2408
2475
|
const varianceArgs = yield* option(layerVarianceStruct(
|
|
@@ -2712,7 +2779,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2712
2779
|
const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
|
|
2713
2780
|
(_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration && ts.isPropertySignature(_.valueDeclaration) && ts.isComputedPropertyName(_.valueDeclaration.name)
|
|
2714
2781
|
);
|
|
2715
|
-
propertiesSymbols.sort((a, b) => b.
|
|
2782
|
+
propertiesSymbols.sort((a, b) => ts.symbolName(b).indexOf("TypeId") - ts.symbolName(a).indexOf("TypeId"));
|
|
2716
2783
|
for (const propertySymbol of propertiesSymbols) {
|
|
2717
2784
|
const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
|
|
2718
2785
|
const varianceArgs = yield* option(effectSchemaVarianceStruct(
|
|
@@ -2741,7 +2808,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2741
2808
|
const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
|
|
2742
2809
|
(_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration && ts.isPropertySignature(_.valueDeclaration) && ts.isComputedPropertyName(_.valueDeclaration.name)
|
|
2743
2810
|
);
|
|
2744
|
-
propertiesSymbols.sort((a, b) => b.
|
|
2811
|
+
propertiesSymbols.sort((a, b) => ts.symbolName(b).indexOf("TypeId") - ts.symbolName(a).indexOf("TypeId"));
|
|
2745
2812
|
for (const propertySymbol of propertiesSymbols) {
|
|
2746
2813
|
const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation);
|
|
2747
2814
|
const varianceArgs = yield* option(contextTagVarianceStruct(
|
|
@@ -2759,7 +2826,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2759
2826
|
);
|
|
2760
2827
|
const pipeCall = cachedBy(
|
|
2761
2828
|
function(node) {
|
|
2762
|
-
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && node.expression.name
|
|
2829
|
+
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && ts.idText(node.expression.name) === "pipe") {
|
|
2763
2830
|
return succeed({
|
|
2764
2831
|
node,
|
|
2765
2832
|
subject: node.expression.expression,
|
|
@@ -2782,11 +2849,13 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2782
2849
|
const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter(
|
|
2783
2850
|
(_) => _.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration && ts.isPropertySignature(_.valueDeclaration) && ts.isComputedPropertyName(_.valueDeclaration.name)
|
|
2784
2851
|
);
|
|
2785
|
-
propertiesSymbols.sort(
|
|
2852
|
+
propertiesSymbols.sort(
|
|
2853
|
+
(a, b) => ts.symbolName(b).indexOf("ScopeTypeId") - ts.symbolName(a).indexOf("ScopeTypeId")
|
|
2854
|
+
);
|
|
2786
2855
|
for (const propertySymbol of propertiesSymbols) {
|
|
2787
2856
|
const computedPropertyExpression = propertySymbol.valueDeclaration.name;
|
|
2788
2857
|
const symbol3 = typeChecker.getSymbolAtLocation(computedPropertyExpression.expression);
|
|
2789
|
-
if (symbol3 && symbol3
|
|
2858
|
+
if (symbol3 && ts.symbolName(symbol3) === "ScopeTypeId") {
|
|
2790
2859
|
return type;
|
|
2791
2860
|
}
|
|
2792
2861
|
}
|
|
@@ -2801,19 +2870,19 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2801
2870
|
if (!thenProperty) return typeParserIssue("not a promise - missing then property", type, atLocation);
|
|
2802
2871
|
const thenType = typeChecker.getTypeOfSymbolAtLocation(thenProperty, atLocation);
|
|
2803
2872
|
if (!thenType) return typeParserIssue("not a promise - missing then property", type, atLocation);
|
|
2804
|
-
for (const callSignature of thenType.
|
|
2873
|
+
for (const callSignature of typeChecker.getSignaturesOfType(thenType, ts.SignatureKind.Call)) {
|
|
2805
2874
|
const parameter = callSignature.parameters[0];
|
|
2806
2875
|
if (!parameter) continue;
|
|
2807
|
-
const parameterType =
|
|
2876
|
+
const parameterType = typeCheckerUtils.getTypeParameterAtPosition(callSignature, 0);
|
|
2808
2877
|
if (!parameterType) continue;
|
|
2809
2878
|
let callbackCallSignatures = [];
|
|
2810
2879
|
let toTest = [parameterType];
|
|
2811
2880
|
while (toTest.length > 0) {
|
|
2812
2881
|
const type2 = toTest.shift();
|
|
2813
2882
|
if (!type2) continue;
|
|
2814
|
-
const callSignatures = type2.
|
|
2883
|
+
const callSignatures = typeChecker.getSignaturesOfType(type2, ts.SignatureKind.Call);
|
|
2815
2884
|
callbackCallSignatures = callbackCallSignatures.concat(callSignatures);
|
|
2816
|
-
if (
|
|
2885
|
+
if (typeCheckerUtils.isUnion(type2)) {
|
|
2817
2886
|
toTest = toTest.concat(type2.types);
|
|
2818
2887
|
}
|
|
2819
2888
|
}
|
|
@@ -2822,7 +2891,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2822
2891
|
if (!callbackParameter) {
|
|
2823
2892
|
continue;
|
|
2824
2893
|
}
|
|
2825
|
-
const callbackParameterType =
|
|
2894
|
+
const callbackParameterType = typeCheckerUtils.getTypeParameterAtPosition(callableType, 0);
|
|
2826
2895
|
if (!callbackParameterType) {
|
|
2827
2896
|
continue;
|
|
2828
2897
|
}
|
|
@@ -2854,7 +2923,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2854
2923
|
if (ts.isCallExpression(schemaCall) && schemaCall.typeArguments && schemaCall.typeArguments.length > 0) {
|
|
2855
2924
|
const selfTypeNode = schemaCall.typeArguments[0];
|
|
2856
2925
|
const schemaIdentifier = schemaCall.expression;
|
|
2857
|
-
if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && schemaIdentifier.name
|
|
2926
|
+
if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && ts.idText(schemaIdentifier.name) === "Class") {
|
|
2858
2927
|
const parsedSchemaModule = yield* pipe(
|
|
2859
2928
|
importedSchemaModule(schemaIdentifier.expression),
|
|
2860
2929
|
option
|
|
@@ -2891,24 +2960,21 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2891
2960
|
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
2892
2961
|
const expression = typeX.expression;
|
|
2893
2962
|
if (ts.isCallExpression(expression)) {
|
|
2894
|
-
const
|
|
2895
|
-
if (ts.isCallExpression(
|
|
2896
|
-
const
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
const
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
Schema: parsedSchemaModule.value
|
|
2910
|
-
};
|
|
2911
|
-
}
|
|
2963
|
+
const schemaTaggedClassTCall = expression.expression;
|
|
2964
|
+
if (ts.isCallExpression(schemaTaggedClassTCall) && schemaTaggedClassTCall.typeArguments && schemaTaggedClassTCall.typeArguments.length > 0) {
|
|
2965
|
+
const selfTypeNode = schemaTaggedClassTCall.typeArguments[0];
|
|
2966
|
+
const schemaIdentifier = schemaTaggedClassTCall.expression;
|
|
2967
|
+
if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && ts.idText(schemaIdentifier.name) === "TaggedClass") {
|
|
2968
|
+
const parsedSchemaModule = yield* pipe(
|
|
2969
|
+
importedSchemaModule(schemaIdentifier.expression),
|
|
2970
|
+
option
|
|
2971
|
+
);
|
|
2972
|
+
if (isSome2(parsedSchemaModule)) {
|
|
2973
|
+
return {
|
|
2974
|
+
className: atLocation.name,
|
|
2975
|
+
selfTypeNode,
|
|
2976
|
+
Schema: parsedSchemaModule.value
|
|
2977
|
+
};
|
|
2912
2978
|
}
|
|
2913
2979
|
}
|
|
2914
2980
|
}
|
|
@@ -2935,24 +3001,21 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2935
3001
|
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
2936
3002
|
const expression = typeX.expression;
|
|
2937
3003
|
if (ts.isCallExpression(expression)) {
|
|
2938
|
-
const
|
|
2939
|
-
if (ts.isCallExpression(
|
|
2940
|
-
const
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
const
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
Schema: parsedSchemaModule.value
|
|
2954
|
-
};
|
|
2955
|
-
}
|
|
3004
|
+
const schemaTaggedErrorTCall = expression.expression;
|
|
3005
|
+
if (ts.isCallExpression(schemaTaggedErrorTCall) && schemaTaggedErrorTCall.typeArguments && schemaTaggedErrorTCall.typeArguments.length > 0) {
|
|
3006
|
+
const selfTypeNode = schemaTaggedErrorTCall.typeArguments[0];
|
|
3007
|
+
const schemaIdentifier = schemaTaggedErrorTCall.expression;
|
|
3008
|
+
if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && ts.idText(schemaIdentifier.name) === "TaggedError") {
|
|
3009
|
+
const parsedSchemaModule = yield* pipe(
|
|
3010
|
+
importedSchemaModule(schemaIdentifier.expression),
|
|
3011
|
+
option
|
|
3012
|
+
);
|
|
3013
|
+
if (isSome2(parsedSchemaModule)) {
|
|
3014
|
+
return {
|
|
3015
|
+
className: atLocation.name,
|
|
3016
|
+
selfTypeNode,
|
|
3017
|
+
Schema: parsedSchemaModule.value
|
|
3018
|
+
};
|
|
2956
3019
|
}
|
|
2957
3020
|
}
|
|
2958
3021
|
}
|
|
@@ -2979,24 +3042,21 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
2979
3042
|
if (ts.isExpressionWithTypeArguments(typeX)) {
|
|
2980
3043
|
const expression = typeX.expression;
|
|
2981
3044
|
if (ts.isCallExpression(expression)) {
|
|
2982
|
-
const
|
|
2983
|
-
if (ts.isCallExpression(
|
|
2984
|
-
const
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
const
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
Schema: parsedSchemaModule.value
|
|
2998
|
-
};
|
|
2999
|
-
}
|
|
3045
|
+
const schemaTaggedRequestTCall = expression.expression;
|
|
3046
|
+
if (ts.isCallExpression(schemaTaggedRequestTCall) && schemaTaggedRequestTCall.typeArguments && schemaTaggedRequestTCall.typeArguments.length > 0) {
|
|
3047
|
+
const selfTypeNode = schemaTaggedRequestTCall.typeArguments[0];
|
|
3048
|
+
const schemaIdentifier = schemaTaggedRequestTCall.expression;
|
|
3049
|
+
if (ts.isPropertyAccessExpression(schemaIdentifier) && ts.isIdentifier(schemaIdentifier.name) && ts.idText(schemaIdentifier.name) === "TaggedRequest") {
|
|
3050
|
+
const parsedSchemaModule = yield* pipe(
|
|
3051
|
+
importedSchemaModule(schemaIdentifier.expression),
|
|
3052
|
+
option
|
|
3053
|
+
);
|
|
3054
|
+
if (isSome2(parsedSchemaModule)) {
|
|
3055
|
+
return {
|
|
3056
|
+
className: atLocation.name,
|
|
3057
|
+
selfTypeNode,
|
|
3058
|
+
Schema: parsedSchemaModule.value
|
|
3059
|
+
};
|
|
3000
3060
|
}
|
|
3001
3061
|
}
|
|
3002
3062
|
}
|
|
@@ -3030,7 +3090,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
3030
3090
|
if (ts.isCallExpression(contextTagCall) && wholeCall.typeArguments && wholeCall.typeArguments.length > 0) {
|
|
3031
3091
|
const contextTagIdentifier = contextTagCall.expression;
|
|
3032
3092
|
const selfTypeNode = wholeCall.typeArguments[0];
|
|
3033
|
-
if (ts.isPropertyAccessExpression(contextTagIdentifier) && ts.isIdentifier(contextTagIdentifier.name) && contextTagIdentifier.name
|
|
3093
|
+
if (ts.isPropertyAccessExpression(contextTagIdentifier) && ts.isIdentifier(contextTagIdentifier.name) && ts.idText(contextTagIdentifier.name) === "Tag") {
|
|
3034
3094
|
const parsedContextModule = yield* pipe(
|
|
3035
3095
|
importedContextModule(contextTagIdentifier.expression),
|
|
3036
3096
|
option
|
|
@@ -3077,7 +3137,7 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
3077
3137
|
if (ts.isCallExpression(effectServiceCall) && effectServiceCall.typeArguments && effectServiceCall.typeArguments.length > 0) {
|
|
3078
3138
|
const effectServiceIdentifier = effectServiceCall.expression;
|
|
3079
3139
|
const selfTypeNode = effectServiceCall.typeArguments[0];
|
|
3080
|
-
if (ts.isPropertyAccessExpression(effectServiceIdentifier) && ts.isIdentifier(effectServiceIdentifier.name) && effectServiceIdentifier.name
|
|
3140
|
+
if (ts.isPropertyAccessExpression(effectServiceIdentifier) && ts.isIdentifier(effectServiceIdentifier.name) && ts.idText(effectServiceIdentifier.name) === "Service") {
|
|
3081
3141
|
const parsedContextTag = yield* pipe(
|
|
3082
3142
|
importedEffectModule(effectServiceIdentifier.expression),
|
|
3083
3143
|
flatMap(() => contextTag(type, atLocation)),
|
|
@@ -3090,10 +3150,10 @@ function make3(ts, tsUtils, typeChecker) {
|
|
|
3090
3150
|
const args2 = wholeCall.arguments[1];
|
|
3091
3151
|
if (ts.isObjectLiteralExpression(args2)) {
|
|
3092
3152
|
for (const property of args2.properties) {
|
|
3093
|
-
if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && property.name
|
|
3153
|
+
if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && ts.idText(property.name) === "accessors" && property.initializer && property.initializer.kind === ts.SyntaxKind.TrueKeyword) {
|
|
3094
3154
|
accessors2 = true;
|
|
3095
3155
|
}
|
|
3096
|
-
if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && property.name
|
|
3156
|
+
if (ts.isPropertyAssignment(property) && property.name && ts.isIdentifier(property.name) && ts.idText(property.name) === "dependencies" && property.initializer && ts.isArrayLiteralExpression(property.initializer)) {
|
|
3097
3157
|
dependencies = property.initializer.elements;
|
|
3098
3158
|
}
|
|
3099
3159
|
}
|
|
@@ -3153,7 +3213,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3153
3213
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3154
3214
|
const typeParser = yield* service(TypeParser);
|
|
3155
3215
|
const changeTracker = yield* service(ChangeTracker);
|
|
3156
|
-
const insertLocation = atLocation.members.length > 0 ? atLocation.members[0].pos : atLocation.
|
|
3216
|
+
const insertLocation = atLocation.members.length > 0 ? atLocation.members[0].pos : atLocation.end - 1;
|
|
3157
3217
|
const effectIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
3158
3218
|
sourceFile,
|
|
3159
3219
|
"effect",
|
|
@@ -3298,7 +3358,11 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3298
3358
|
ts.NodeBuilderFlags.NoTruncation
|
|
3299
3359
|
);
|
|
3300
3360
|
if (!signatureDeclaration) return yield* fail("error generating signature");
|
|
3301
|
-
const returnType = yield* generateReturnType(
|
|
3361
|
+
const returnType = yield* generateReturnType(
|
|
3362
|
+
typeChecker.getReturnTypeOfSignature(signature),
|
|
3363
|
+
atLocation2,
|
|
3364
|
+
className2
|
|
3365
|
+
);
|
|
3302
3366
|
return ts.factory.createFunctionTypeNode(
|
|
3303
3367
|
signatureDeclaration.typeParameters,
|
|
3304
3368
|
signatureDeclaration.parameters,
|
|
@@ -3308,7 +3372,7 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3308
3372
|
for (const { property, propertyType } of involvedMembers) {
|
|
3309
3373
|
const callSignatures = [];
|
|
3310
3374
|
let propertyDeclaration = void 0;
|
|
3311
|
-
for (const signature of propertyType.
|
|
3375
|
+
for (const signature of typeChecker.getSignaturesOfType(propertyType, ts.SignatureKind.Call)) {
|
|
3312
3376
|
yield* pipe(
|
|
3313
3377
|
proxySignature(signature, atLocation, className),
|
|
3314
3378
|
map3((sig) => {
|
|
@@ -3319,17 +3383,18 @@ var generate = fn("writeTagClassAccessors.generate")(function* (sourceFile, serv
|
|
|
3319
3383
|
}
|
|
3320
3384
|
const allSignatures = ts.factory.createIntersectionTypeNode(callSignatures);
|
|
3321
3385
|
const type = tsUtils.simplifyTypeNode(allSignatures);
|
|
3322
|
-
propertyDeclaration = createFunctionProperty(className,
|
|
3386
|
+
propertyDeclaration = createFunctionProperty(className, ts.symbolName(property), type, callSignatures.length > 1);
|
|
3323
3387
|
const oldProperty = atLocation.members.filter(ts.isPropertyDeclaration).find((p) => {
|
|
3324
3388
|
const symbol3 = typeChecker.getSymbolAtLocation(p.name);
|
|
3325
|
-
return symbol3
|
|
3389
|
+
return symbol3 && ts.symbolName(symbol3) === ts.symbolName(property);
|
|
3326
3390
|
});
|
|
3327
3391
|
if (oldProperty) {
|
|
3392
|
+
const start = ts.getTokenPosOfNode(oldProperty, sourceFile);
|
|
3328
3393
|
changeTracker.deleteRange(sourceFile, {
|
|
3329
|
-
pos:
|
|
3330
|
-
end: oldProperty.
|
|
3394
|
+
pos: start,
|
|
3395
|
+
end: oldProperty.end
|
|
3331
3396
|
});
|
|
3332
|
-
changeTracker.insertNodeAt(sourceFile,
|
|
3397
|
+
changeTracker.insertNodeAt(sourceFile, start, propertyDeclaration);
|
|
3333
3398
|
} else {
|
|
3334
3399
|
changeTracker.insertNodeAt(sourceFile, insertLocation, propertyDeclaration, { suffix: "\n" });
|
|
3335
3400
|
}
|
|
@@ -3348,14 +3413,14 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
|
|
|
3348
3413
|
const involvedMembers = [];
|
|
3349
3414
|
for (const property of typeChecker.getPropertiesOfType(Service)) {
|
|
3350
3415
|
const propertyType = typeChecker.getTypeOfSymbolAtLocation(property, node);
|
|
3351
|
-
const callSignatures = propertyType.
|
|
3416
|
+
const callSignatures = typeChecker.getSignaturesOfType(propertyType, ts.SignatureKind.Call);
|
|
3352
3417
|
if (callSignatures.length > 0) {
|
|
3353
3418
|
const withTypeParameters = callSignatures.filter((_) => _.typeParameters && _.typeParameters.length > 0);
|
|
3354
3419
|
if (callSignatures.length > 1 || withTypeParameters.length > 0) involvedMembers.push({ property, propertyType });
|
|
3355
3420
|
}
|
|
3356
3421
|
}
|
|
3357
3422
|
const hash2 = involvedMembers.map(({ property, propertyType }) => {
|
|
3358
|
-
return
|
|
3423
|
+
return ts.symbolName(property) + ": " + typeChecker.typeToString(propertyType);
|
|
3359
3424
|
}).concat([className.text]).join("\n");
|
|
3360
3425
|
return { Service, className, atLocation: node, hash: cyrb53(hash2), involvedMembers };
|
|
3361
3426
|
});
|
|
@@ -3481,10 +3546,10 @@ var effectDataClasses = createCompletion({
|
|
|
3481
3546
|
})
|
|
3482
3547
|
});
|
|
3483
3548
|
|
|
3484
|
-
// node_modules/.pnpm/effect@3.17.
|
|
3549
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/encoding/common.js
|
|
3485
3550
|
var encoder = /* @__PURE__ */ new TextEncoder();
|
|
3486
3551
|
|
|
3487
|
-
// node_modules/.pnpm/effect@3.17.
|
|
3552
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/encoding/base64.js
|
|
3488
3553
|
var encode = (bytes) => {
|
|
3489
3554
|
const length = bytes.length;
|
|
3490
3555
|
let result = "";
|
|
@@ -3510,10 +3575,10 @@ var encode = (bytes) => {
|
|
|
3510
3575
|
};
|
|
3511
3576
|
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", "+", "/"];
|
|
3512
3577
|
|
|
3513
|
-
// node_modules/.pnpm/effect@3.17.
|
|
3578
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/internal/encoding/base64Url.js
|
|
3514
3579
|
var encode2 = (data) => encode(data).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
3515
3580
|
|
|
3516
|
-
// node_modules/.pnpm/effect@3.17.
|
|
3581
|
+
// node_modules/.pnpm/effect@3.17.8/node_modules/effect/dist/esm/Encoding.js
|
|
3517
3582
|
var encodeBase64Url = (input) => typeof input === "string" ? encode2(encoder.encode(input)) : encode2(input);
|
|
3518
3583
|
|
|
3519
3584
|
// src/diagnostics/classSelfMismatch.ts
|
|
@@ -3547,12 +3612,12 @@ var classSelfMismatch = createDiagnostic({
|
|
|
3547
3612
|
let actualName = "";
|
|
3548
3613
|
if (ts.isTypeReferenceNode(selfTypeNode)) {
|
|
3549
3614
|
if (ts.isIdentifier(selfTypeNode.typeName)) {
|
|
3550
|
-
actualName = selfTypeNode.typeName
|
|
3615
|
+
actualName = ts.idText(selfTypeNode.typeName);
|
|
3551
3616
|
} else if (ts.isQualifiedName(selfTypeNode.typeName)) {
|
|
3552
|
-
actualName = selfTypeNode.typeName.right
|
|
3617
|
+
actualName = ts.idText(selfTypeNode.typeName.right);
|
|
3553
3618
|
}
|
|
3554
3619
|
}
|
|
3555
|
-
const expectedName = className
|
|
3620
|
+
const expectedName = ts.idText(className);
|
|
3556
3621
|
if (actualName !== expectedName) {
|
|
3557
3622
|
report({
|
|
3558
3623
|
location: selfTypeNode,
|
|
@@ -3637,11 +3702,12 @@ var effectInVoidSuccess = createDiagnostic({
|
|
|
3637
3702
|
const ts = yield* service(TypeScriptApi);
|
|
3638
3703
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3639
3704
|
const typeParser = yield* service(TypeParser);
|
|
3705
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
3640
3706
|
const checkForEffectInVoid = fn("effectInVoidSuccess.checkForEffectInVoid")(function* (node, expectedType, valueNode, realType) {
|
|
3641
3707
|
const expectedEffect = yield* typeParser.effectType(expectedType, node);
|
|
3642
3708
|
const realEffect = yield* typeParser.effectType(realType, valueNode);
|
|
3643
3709
|
if (expectedEffect.A.flags & ts.TypeFlags.Void) {
|
|
3644
|
-
const voidValueTypes = unrollUnionMembers(realEffect.A);
|
|
3710
|
+
const voidValueTypes = typeCheckerUtils.unrollUnionMembers(realEffect.A);
|
|
3645
3711
|
const voidedEffect = yield* firstSuccessOf(
|
|
3646
3712
|
voidValueTypes.map((_) => map3(typeParser.strictEffectType(_, node), () => _))
|
|
3647
3713
|
);
|
|
@@ -3803,12 +3869,14 @@ var importFromBarrel = createDiagnostic({
|
|
|
3803
3869
|
const moduleSymbol = resolveExternalModuleName(importDeclaration.moduleSpecifier);
|
|
3804
3870
|
if (!moduleSymbol) return;
|
|
3805
3871
|
if (!moduleSymbol.exports) return;
|
|
3806
|
-
const sourceFile2 =
|
|
3872
|
+
const sourceFile2 = tsUtils.getSourceFileOfNode(importDeclaration);
|
|
3873
|
+
if (!sourceFile2) return;
|
|
3807
3874
|
const nodeForSymbol = element.propertyName || element.name;
|
|
3808
3875
|
const aliasSymbol = element.name || element.propertyName;
|
|
3809
|
-
const aliasedName = aliasSymbol
|
|
3876
|
+
const aliasedName = ts.idText(aliasSymbol);
|
|
3810
3877
|
if (!ts.isIdentifier(nodeForSymbol)) return;
|
|
3811
|
-
const importedName = nodeForSymbol
|
|
3878
|
+
const importedName = ts.idText(nodeForSymbol);
|
|
3879
|
+
if (!importedName) return;
|
|
3812
3880
|
const reexportedSymbol = moduleSymbol.exports.get(ts.escapeLeadingUnderscores(importedName));
|
|
3813
3881
|
if (!reexportedSymbol) return;
|
|
3814
3882
|
if (!(reexportedSymbol.declarations && reexportedSymbol.declarations.length === 1)) return;
|
|
@@ -3820,7 +3888,8 @@ var importFromBarrel = createDiagnostic({
|
|
|
3820
3888
|
const originalModuleSymbol = resolveExternalModuleName(exportDeclaration.moduleSpecifier);
|
|
3821
3889
|
if (!originalModuleSymbol) return;
|
|
3822
3890
|
if (!originalModuleSymbol.valueDeclaration) return;
|
|
3823
|
-
const originalSourceFile = originalModuleSymbol.valueDeclaration
|
|
3891
|
+
const originalSourceFile = tsUtils.getSourceFileOfNode(originalModuleSymbol.valueDeclaration);
|
|
3892
|
+
if (!originalSourceFile) return;
|
|
3824
3893
|
const unbarrelledFileName = getModuleSpecifier(
|
|
3825
3894
|
program.getCompilerOptions(),
|
|
3826
3895
|
sourceFile2,
|
|
@@ -3913,6 +3982,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
3913
3982
|
apply: fn("leakingRequirements.apply")(function* (sourceFile, report) {
|
|
3914
3983
|
const ts = yield* service(TypeScriptApi);
|
|
3915
3984
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
3985
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
3916
3986
|
const typeParser = yield* service(TypeParser);
|
|
3917
3987
|
const typeOrder = yield* deterministicTypeOrder;
|
|
3918
3988
|
const parseLeakedRequirements = cachedBy(
|
|
@@ -3930,10 +4000,16 @@ var leakingRequirements = createDiagnostic({
|
|
|
3930
4000
|
typeParser.effectType(servicePropertyType, atLocation),
|
|
3931
4001
|
map3((_) => effectContextType = _.R),
|
|
3932
4002
|
orElse2(() => {
|
|
3933
|
-
const servicePropertyCallSignatures =
|
|
4003
|
+
const servicePropertyCallSignatures = typeChecker.getSignaturesOfType(
|
|
4004
|
+
servicePropertyType,
|
|
4005
|
+
ts.SignatureKind.Call
|
|
4006
|
+
);
|
|
3934
4007
|
if (servicePropertyCallSignatures.length === 1) {
|
|
3935
4008
|
return pipe(
|
|
3936
|
-
typeParser.effectType(
|
|
4009
|
+
typeParser.effectType(
|
|
4010
|
+
typeChecker.getReturnTypeOfSignature(servicePropertyCallSignatures[0]),
|
|
4011
|
+
atLocation
|
|
4012
|
+
),
|
|
3937
4013
|
map3((_) => {
|
|
3938
4014
|
effectContextType = _.R;
|
|
3939
4015
|
})
|
|
@@ -3945,7 +4021,7 @@ var leakingRequirements = createDiagnostic({
|
|
|
3945
4021
|
);
|
|
3946
4022
|
if (effectContextType) {
|
|
3947
4023
|
effectMembers++;
|
|
3948
|
-
const { allIndexes } = yield* appendToUniqueTypesMap(
|
|
4024
|
+
const { allIndexes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
3949
4025
|
memory,
|
|
3950
4026
|
effectContextType,
|
|
3951
4027
|
(type) => {
|
|
@@ -3993,7 +4069,7 @@ More info at https://effect.website/docs/requirements-management/layers/#avoidin
|
|
|
3993
4069
|
while (nodeToVisit.length > 0) {
|
|
3994
4070
|
const node = nodeToVisit.shift();
|
|
3995
4071
|
const typesToCheck = [];
|
|
3996
|
-
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && node.expression.name
|
|
4072
|
+
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && ts.idText(node.expression.name) === "GenericTag") {
|
|
3997
4073
|
typesToCheck.push([typeChecker.getTypeAtLocation(node), node]);
|
|
3998
4074
|
} else if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
3999
4075
|
const classSym = typeChecker.getSymbolAtLocation(node.name);
|
|
@@ -4031,13 +4107,14 @@ var missingEffectContext = createDiagnostic({
|
|
|
4031
4107
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
4032
4108
|
const typeParser = yield* service(TypeParser);
|
|
4033
4109
|
const typeOrder = yield* deterministicTypeOrder;
|
|
4110
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
4034
4111
|
const checkForMissingContextTypes = (node, expectedType, valueNode, realType) => pipe(
|
|
4035
4112
|
all(
|
|
4036
4113
|
typeParser.effectType(expectedType, node),
|
|
4037
4114
|
typeParser.effectType(realType, valueNode)
|
|
4038
4115
|
),
|
|
4039
|
-
|
|
4040
|
-
([expectedEffect, realEffect]) => getMissingTypeEntriesInTargetType(
|
|
4116
|
+
map3(
|
|
4117
|
+
([expectedEffect, realEffect]) => typeCheckerUtils.getMissingTypeEntriesInTargetType(
|
|
4041
4118
|
realEffect.R,
|
|
4042
4119
|
expectedEffect.R
|
|
4043
4120
|
)
|
|
@@ -4079,6 +4156,7 @@ var missingEffectError = createDiagnostic({
|
|
|
4079
4156
|
const ts = yield* service(TypeScriptApi);
|
|
4080
4157
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
4081
4158
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
4159
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
4082
4160
|
const typeParser = yield* service(TypeParser);
|
|
4083
4161
|
const typeOrder = yield* deterministicTypeOrder;
|
|
4084
4162
|
const effectModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
@@ -4099,13 +4177,13 @@ var missingEffectError = createDiagnostic({
|
|
|
4099
4177
|
typeParser.effectType(expectedType, node),
|
|
4100
4178
|
typeParser.effectType(realType, valueNode)
|
|
4101
4179
|
),
|
|
4102
|
-
|
|
4180
|
+
map3(
|
|
4103
4181
|
([expectedEffect, realEffect]) => pipe(
|
|
4104
|
-
getMissingTypeEntriesInTargetType(
|
|
4182
|
+
typeCheckerUtils.getMissingTypeEntriesInTargetType(
|
|
4105
4183
|
realEffect.E,
|
|
4106
4184
|
expectedEffect.E
|
|
4107
4185
|
),
|
|
4108
|
-
|
|
4186
|
+
(missingErrorTypes) => ({ missingErrorTypes, expectedErrorType: expectedEffect.E })
|
|
4109
4187
|
)
|
|
4110
4188
|
)
|
|
4111
4189
|
);
|
|
@@ -4129,14 +4207,18 @@ var missingEffectError = createDiagnostic({
|
|
|
4129
4207
|
description: "Catch all errors with Effect.catchAll",
|
|
4130
4208
|
apply: gen(function* () {
|
|
4131
4209
|
const changeTracker = yield* service(ChangeTracker);
|
|
4132
|
-
changeTracker.insertText(
|
|
4133
|
-
|
|
4210
|
+
changeTracker.insertText(
|
|
4211
|
+
sourceFile,
|
|
4212
|
+
ts.getTokenPosOfNode(valueNode, sourceFile),
|
|
4213
|
+
effectModuleIdentifier + ".catchAll("
|
|
4214
|
+
);
|
|
4215
|
+
changeTracker.insertText(sourceFile, valueNode.end, ", () => ");
|
|
4134
4216
|
changeTracker.insertNodeAt(
|
|
4135
4217
|
sourceFile,
|
|
4136
|
-
valueNode.
|
|
4218
|
+
valueNode.end,
|
|
4137
4219
|
createDieMessage("TODO: catchAll not implemented")
|
|
4138
4220
|
);
|
|
4139
|
-
changeTracker.insertText(sourceFile, valueNode.
|
|
4221
|
+
changeTracker.insertText(sourceFile, valueNode.end, ")");
|
|
4140
4222
|
})
|
|
4141
4223
|
});
|
|
4142
4224
|
}
|
|
@@ -4173,22 +4255,27 @@ var missingEffectError = createDiagnostic({
|
|
|
4173
4255
|
description: "Catch unexpected errors with Effect.catchTag",
|
|
4174
4256
|
apply: gen(function* () {
|
|
4175
4257
|
const changeTracker = yield* service(ChangeTracker);
|
|
4176
|
-
changeTracker.insertText(
|
|
4177
|
-
|
|
4258
|
+
changeTracker.insertText(
|
|
4259
|
+
sourceFile,
|
|
4260
|
+
ts.getTokenPosOfNode(valueNode, sourceFile),
|
|
4261
|
+
effectModuleIdentifier + ".catchTags("
|
|
4262
|
+
);
|
|
4263
|
+
changeTracker.insertText(sourceFile, valueNode.end, ", ");
|
|
4178
4264
|
changeTracker.insertNodeAt(
|
|
4179
4265
|
sourceFile,
|
|
4180
|
-
valueNode.
|
|
4266
|
+
valueNode.end,
|
|
4181
4267
|
ts.factory.createObjectLiteralExpression(propertyAssignments)
|
|
4182
4268
|
);
|
|
4183
|
-
changeTracker.insertText(sourceFile, valueNode.
|
|
4269
|
+
changeTracker.insertText(sourceFile, valueNode.end, ")");
|
|
4184
4270
|
})
|
|
4185
4271
|
});
|
|
4186
4272
|
}
|
|
4187
4273
|
}
|
|
4274
|
+
const typeNames = sortTypes(result.missingErrorTypes).map((_) => typeChecker.typeToString(_));
|
|
4188
4275
|
report(
|
|
4189
4276
|
{
|
|
4190
4277
|
location: node,
|
|
4191
|
-
messageText: `Missing '${
|
|
4278
|
+
messageText: `Missing '${typeNames.join(" | ")}' in the expected Effect errors.`,
|
|
4192
4279
|
fixes
|
|
4193
4280
|
}
|
|
4194
4281
|
);
|
|
@@ -4208,6 +4295,7 @@ var missingEffectServiceDependency = createDiagnostic({
|
|
|
4208
4295
|
apply: fn("missingEffectServiceDependency.apply")(function* (sourceFile, report) {
|
|
4209
4296
|
const ts = yield* service(TypeScriptApi);
|
|
4210
4297
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
4298
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
4211
4299
|
const typeParser = yield* service(TypeParser);
|
|
4212
4300
|
const nodeToVisit = [];
|
|
4213
4301
|
const appendNodeToVisit = (node) => {
|
|
@@ -4238,7 +4326,7 @@ var missingEffectServiceDependency = createDiagnostic({
|
|
|
4238
4326
|
if (layerResult) {
|
|
4239
4327
|
const servicesMemory = /* @__PURE__ */ new Map();
|
|
4240
4328
|
const excludeNever = (type) => succeed((type.flags & ts.TypeFlags.Never) !== 0);
|
|
4241
|
-
const { allIndexes: requiredIndexes } = yield* appendToUniqueTypesMap(
|
|
4329
|
+
const { allIndexes: requiredIndexes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
4242
4330
|
servicesMemory,
|
|
4243
4331
|
layerResult.RIn,
|
|
4244
4332
|
excludeNever
|
|
@@ -4249,8 +4337,8 @@ var missingEffectServiceDependency = createDiagnostic({
|
|
|
4249
4337
|
let types = [];
|
|
4250
4338
|
if (dependenciesProperty) {
|
|
4251
4339
|
const dependenciesTypes = typeChecker.getTypeOfSymbolAtLocation(dependenciesProperty, options);
|
|
4252
|
-
const numberIndexType = dependenciesTypes.
|
|
4253
|
-
types = numberIndexType ? unrollUnionMembers(numberIndexType) : [];
|
|
4340
|
+
const numberIndexType = typeChecker.getIndexTypeOfType(dependenciesTypes, ts.IndexKind.Number);
|
|
4341
|
+
types = numberIndexType ? typeCheckerUtils.unrollUnionMembers(numberIndexType) : [];
|
|
4254
4342
|
}
|
|
4255
4343
|
for (const depType of types) {
|
|
4256
4344
|
const depLayerResult = yield* pipe(
|
|
@@ -4258,7 +4346,7 @@ var missingEffectServiceDependency = createDiagnostic({
|
|
|
4258
4346
|
orElse2(() => void_)
|
|
4259
4347
|
);
|
|
4260
4348
|
if (depLayerResult) {
|
|
4261
|
-
const { allIndexes } = yield* appendToUniqueTypesMap(
|
|
4349
|
+
const { allIndexes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
4262
4350
|
servicesMemory,
|
|
4263
4351
|
depLayerResult.ROut,
|
|
4264
4352
|
excludeNever
|
|
@@ -4447,7 +4535,7 @@ var multipleEffectProvide = createDiagnostic({
|
|
|
4447
4535
|
"Layer"
|
|
4448
4536
|
) || "Layer";
|
|
4449
4537
|
const parseEffectProvideLayer = (node) => {
|
|
4450
|
-
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && node.expression.name
|
|
4538
|
+
if (ts.isCallExpression(node) && ts.isPropertyAccessExpression(node.expression) && ts.isIdentifier(node.expression.name) && ts.idText(node.expression.name) === "provide" && node.arguments.length > 0) {
|
|
4451
4539
|
const layer = node.arguments[0];
|
|
4452
4540
|
const type = typeChecker.getTypeAtLocation(layer);
|
|
4453
4541
|
return pipe(
|
|
@@ -4483,8 +4571,8 @@ var multipleEffectProvide = createDiagnostic({
|
|
|
4483
4571
|
apply: gen(function* () {
|
|
4484
4572
|
const changeTracker = yield* service(ChangeTracker);
|
|
4485
4573
|
changeTracker.deleteRange(sourceFile, {
|
|
4486
|
-
pos: chunk[0].node
|
|
4487
|
-
end: chunk[chunk.length - 1].node.
|
|
4574
|
+
pos: ts.getTokenPosOfNode(chunk[0].node, sourceFile),
|
|
4575
|
+
end: chunk[chunk.length - 1].node.end
|
|
4488
4576
|
});
|
|
4489
4577
|
const newNode = ts.factory.createCallExpression(
|
|
4490
4578
|
ts.factory.createPropertyAccessExpression(
|
|
@@ -4501,7 +4589,7 @@ var multipleEffectProvide = createDiagnostic({
|
|
|
4501
4589
|
chunk.map((c) => c.layer)
|
|
4502
4590
|
)]
|
|
4503
4591
|
);
|
|
4504
|
-
changeTracker.insertNodeAt(sourceFile, chunk[0].node
|
|
4592
|
+
changeTracker.insertNodeAt(sourceFile, ts.getTokenPosOfNode(chunk[0].node, sourceFile), newNode);
|
|
4505
4593
|
})
|
|
4506
4594
|
}]
|
|
4507
4595
|
});
|
|
@@ -4707,6 +4795,7 @@ var scopeInLayerEffect = createDiagnostic({
|
|
|
4707
4795
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
4708
4796
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
4709
4797
|
const typeParser = yield* service(TypeParser);
|
|
4798
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
4710
4799
|
const layerModuleIdentifier = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
4711
4800
|
sourceFile,
|
|
4712
4801
|
"effect",
|
|
@@ -4717,22 +4806,13 @@ var scopeInLayerEffect = createDiagnostic({
|
|
|
4717
4806
|
const expression = node.expression;
|
|
4718
4807
|
if (!ts.isPropertyAccessExpression(expression)) return;
|
|
4719
4808
|
const calledModule = expression.expression;
|
|
4720
|
-
if (!(ts.isIdentifier(calledModule) && calledModule
|
|
4809
|
+
if (!(ts.isIdentifier(calledModule) && ts.idText(calledModule) === layerModuleIdentifier)) return;
|
|
4721
4810
|
const methodIdentifier = expression.name;
|
|
4722
|
-
if (!(ts.isIdentifier(methodIdentifier) && methodIdentifier.
|
|
4811
|
+
if (!(ts.isIdentifier(methodIdentifier) && ts.idText(methodIdentifier).toLowerCase().startsWith("effect"))) return;
|
|
4723
4812
|
return { methodIdentifier };
|
|
4724
4813
|
}
|
|
4725
4814
|
const reportIfLayerRequireScope = (type, node, methodIdentifier) => {
|
|
4726
|
-
|
|
4727
|
-
const entries = [];
|
|
4728
|
-
while (toCheck.length > 0) {
|
|
4729
|
-
const type2 = toCheck.pop();
|
|
4730
|
-
if (type2.isUnion()) {
|
|
4731
|
-
toCheck = toCheck.concat(type2.types);
|
|
4732
|
-
} else {
|
|
4733
|
-
entries.push(type2);
|
|
4734
|
-
}
|
|
4735
|
-
}
|
|
4815
|
+
const entries = typeCheckerUtils.unrollUnionMembers(type);
|
|
4736
4816
|
return pipe(
|
|
4737
4817
|
firstSuccessOf(entries.map((type2) => typeParser.scopeType(type2, node))),
|
|
4738
4818
|
map3(
|
|
@@ -4804,6 +4884,7 @@ var strictBooleanExpressions = createDiagnostic({
|
|
|
4804
4884
|
apply: fn("strictBooleanExpressions.apply")(function* (sourceFile, report) {
|
|
4805
4885
|
const ts = yield* service(TypeScriptApi);
|
|
4806
4886
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
4887
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
4807
4888
|
const conditionChecks = /* @__PURE__ */ new WeakMap();
|
|
4808
4889
|
const nodeToVisit = [];
|
|
4809
4890
|
const appendNodeToVisit = (node) => {
|
|
@@ -4844,7 +4925,7 @@ var strictBooleanExpressions = createDiagnostic({
|
|
|
4844
4925
|
let typesToCheck = [constrainedType || nodeType];
|
|
4845
4926
|
while (typesToCheck.length > 0) {
|
|
4846
4927
|
const type = typesToCheck.pop();
|
|
4847
|
-
if (
|
|
4928
|
+
if (typeCheckerUtils.isUnion(type)) {
|
|
4848
4929
|
typesToCheck = typesToCheck.concat(type.types);
|
|
4849
4930
|
continue;
|
|
4850
4931
|
}
|
|
@@ -5096,15 +5177,15 @@ var unsupportedServiceAccessors = createDiagnostic({
|
|
|
5096
5177
|
node.members?.forEach((member) => {
|
|
5097
5178
|
if (ts.isPropertyDeclaration(member) && member.modifiers?.some((mod) => mod.kind === ts.SyntaxKind.StaticKeyword)) {
|
|
5098
5179
|
if (member.name && ts.isIdentifier(member.name)) {
|
|
5099
|
-
existingStaticMembers.add(member.name
|
|
5180
|
+
existingStaticMembers.add(ts.idText(member.name));
|
|
5100
5181
|
}
|
|
5101
5182
|
}
|
|
5102
5183
|
});
|
|
5103
5184
|
const missingMembers = parseResult.involvedMembers.filter(
|
|
5104
|
-
({ property }) => !existingStaticMembers.has(
|
|
5185
|
+
({ property }) => !existingStaticMembers.has(ts.symbolName(property))
|
|
5105
5186
|
);
|
|
5106
5187
|
if (missingMembers.length > 0) {
|
|
5107
|
-
const memberNames = missingMembers.map(({ property }) => `'${
|
|
5188
|
+
const memberNames = missingMembers.map(({ property }) => `'${ts.symbolName(property)}'`).join(", ");
|
|
5108
5189
|
report({
|
|
5109
5190
|
location: parseResult.className,
|
|
5110
5191
|
messageText: `Even if accessors are enabled, accessors for ${memberNames} won't be available because the signature have generic type parameters or multiple call signatures.`,
|
|
@@ -5114,7 +5195,7 @@ var unsupportedServiceAccessors = createDiagnostic({
|
|
|
5114
5195
|
apply: gen(function* () {
|
|
5115
5196
|
const changeTracker = yield* service(ChangeTracker);
|
|
5116
5197
|
const comment = "// @effect-codegens accessors\n";
|
|
5117
|
-
changeTracker.insertText(sourceFile,
|
|
5198
|
+
changeTracker.insertText(sourceFile, ts.getTokenPosOfNode(node, sourceFile), comment);
|
|
5118
5199
|
})
|
|
5119
5200
|
}]
|
|
5120
5201
|
});
|
|
@@ -5318,7 +5399,7 @@ var genFunctionStar = createCompletion({
|
|
|
5318
5399
|
const genMemberSymbol = type.getProperty("gen");
|
|
5319
5400
|
if (!genMemberSymbol) return [];
|
|
5320
5401
|
const genType = typeChecker.getTypeOfSymbolAtLocation(genMemberSymbol, accessedObject);
|
|
5321
|
-
if (genType.
|
|
5402
|
+
if (typeChecker.getSignaturesOfType(genType, ts.SignatureKind.Call).length === 0) return [];
|
|
5322
5403
|
const span = ts.createTextSpan(
|
|
5323
5404
|
accessedObject.end + 1,
|
|
5324
5405
|
Math.max(0, position - accessedObject.end - 1)
|
|
@@ -5575,6 +5656,13 @@ var makeAutoImportProvider = fn("TypeScriptApi")(function* (fromSourceFile) {
|
|
|
5575
5656
|
exportName: namedExport.name
|
|
5576
5657
|
}
|
|
5577
5658
|
});
|
|
5659
|
+
mapFromBarrelToBarrel.set(reexportedFile.resolvedModule.resolvedFileName, {
|
|
5660
|
+
...mapFromBarrelToBarrel.get(reexportedFile.resolvedModule.resolvedFileName) || {},
|
|
5661
|
+
[namedExport.name]: {
|
|
5662
|
+
fileName: reexportedFile.resolvedModule.resolvedFileName,
|
|
5663
|
+
exportName: namedExport.name
|
|
5664
|
+
}
|
|
5665
|
+
});
|
|
5578
5666
|
}
|
|
5579
5667
|
}
|
|
5580
5668
|
}
|
|
@@ -6031,7 +6119,7 @@ function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
|
|
|
6031
6119
|
for (const node of tsUtils.getAncestorNodesInRange(sourceFile, textRange)) {
|
|
6032
6120
|
if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && tsUtils.isNodeInRange(textRange)(node.name)) {
|
|
6033
6121
|
const type = typeChecker.getTypeAtLocation(node);
|
|
6034
|
-
for (const callSig of type.
|
|
6122
|
+
for (const callSig of typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call)) {
|
|
6035
6123
|
if (callSig.parameters.length >= 2 && isSymbolFromEffectRpcClientModule(callSig.parameters[1])) {
|
|
6036
6124
|
rpcName = node.name.text;
|
|
6037
6125
|
callNode = node.name;
|
|
@@ -6078,7 +6166,7 @@ function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
|
|
|
6078
6166
|
if (result.length === 0) return applicableGotoDefinition;
|
|
6079
6167
|
const effectRpcResult = result.map(([node]) => ({
|
|
6080
6168
|
fileName: node.getSourceFile().fileName,
|
|
6081
|
-
textSpan: ts.createTextSpan(node.getStart(), node.
|
|
6169
|
+
textSpan: ts.createTextSpan(node.getStart(), node.end - node.getStart()),
|
|
6082
6170
|
kind: ts.ScriptElementKind.constElement,
|
|
6083
6171
|
name: rpcName,
|
|
6084
6172
|
containerKind: ts.ScriptElementKind.constElement,
|
|
@@ -6091,7 +6179,7 @@ function effectRpcDefinition(applicableGotoDefinition, sourceFile, position) {
|
|
|
6091
6179
|
};
|
|
6092
6180
|
}
|
|
6093
6181
|
return {
|
|
6094
|
-
textSpan: ts.createTextSpan(callNode.getStart(), callNode.
|
|
6182
|
+
textSpan: ts.createTextSpan(callNode.getStart(), callNode.end - callNode.getStart()),
|
|
6095
6183
|
definitions: effectRpcResult
|
|
6096
6184
|
};
|
|
6097
6185
|
});
|
|
@@ -6127,7 +6215,7 @@ var middlewareGenLike = fn("middlewareGenLike")(function* (sourceFile, _span, pr
|
|
|
6127
6215
|
parseType(possiblyGen),
|
|
6128
6216
|
map3((_) => {
|
|
6129
6217
|
const argsCloseParen = ts.findChildOfKind(_.generatorFunction, ts.SyntaxKind.CloseParenToken, sourceFile);
|
|
6130
|
-
if (argsCloseParen && _.body && inlayHint.position >= argsCloseParen.
|
|
6218
|
+
if (argsCloseParen && _.body && inlayHint.position >= argsCloseParen.end && inlayHint.position <= _.body.getStart(sourceFile)) {
|
|
6131
6219
|
shouldOmit = true;
|
|
6132
6220
|
}
|
|
6133
6221
|
}),
|
|
@@ -6223,9 +6311,9 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
6223
6311
|
),
|
|
6224
6312
|
map3((_) => makeSymbolDisplayParts("Effect Type Parameters", _.A, _.E, _.R)),
|
|
6225
6313
|
orElse2(() => {
|
|
6226
|
-
const callSignatues = type.
|
|
6314
|
+
const callSignatues = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
6227
6315
|
if (callSignatues.length !== 1) return succeed([]);
|
|
6228
|
-
const returnType = callSignatues[0]
|
|
6316
|
+
const returnType = typeChecker.getReturnTypeOfSignature(callSignatues[0]);
|
|
6229
6317
|
return pipe(
|
|
6230
6318
|
typeParser.effectType(
|
|
6231
6319
|
returnType,
|
|
@@ -6236,8 +6324,8 @@ function effectTypeArgs(sourceFile, position, quickInfo2) {
|
|
|
6236
6324
|
})
|
|
6237
6325
|
);
|
|
6238
6326
|
if (!quickInfo2) {
|
|
6239
|
-
const start =
|
|
6240
|
-
const end = node.
|
|
6327
|
+
const start = ts.getTokenPosOfNode(node, sourceFile);
|
|
6328
|
+
const end = node.end;
|
|
6241
6329
|
return {
|
|
6242
6330
|
kind: ts.ScriptElementKind.callSignatureElement,
|
|
6243
6331
|
kindModifiers: "",
|
|
@@ -10466,6 +10554,7 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
10466
10554
|
const ts = yield* service(TypeScriptApi);
|
|
10467
10555
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
10468
10556
|
const typeParser = yield* service(TypeParser);
|
|
10557
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
10469
10558
|
const excludeNever = (type) => succeed((type.flags & ts.TypeFlags.Never) !== 0);
|
|
10470
10559
|
const maybePipe = yield* option(typeParser.pipeCall(node));
|
|
10471
10560
|
if (isSome2(maybePipe)) {
|
|
@@ -10483,12 +10572,12 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
10483
10572
|
all(...node.arguments.map((_) => processLayerGraphNode(ctx, _, void 0)))
|
|
10484
10573
|
);
|
|
10485
10574
|
if (isSome2(argNodes) && argNodes.value.length === node.arguments.length) {
|
|
10486
|
-
const { allIndexes: outTypes } = yield* appendToUniqueTypesMap(
|
|
10575
|
+
const { allIndexes: outTypes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
10487
10576
|
ctx.services,
|
|
10488
10577
|
maybeLayer.value.ROut,
|
|
10489
10578
|
excludeNever
|
|
10490
10579
|
);
|
|
10491
|
-
const { allIndexes: inTypes } = yield* appendToUniqueTypesMap(
|
|
10580
|
+
const { allIndexes: inTypes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
10492
10581
|
ctx.services,
|
|
10493
10582
|
maybeLayer.value.RIn,
|
|
10494
10583
|
excludeNever
|
|
@@ -10506,18 +10595,18 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
10506
10595
|
if (pipedInGraphNode && ts.isExpression(node)) {
|
|
10507
10596
|
const type = typeChecker.getContextualType(node);
|
|
10508
10597
|
if (type) {
|
|
10509
|
-
const callSignatures = type.
|
|
10598
|
+
const callSignatures = typeChecker.getSignaturesOfType(type, ts.SignatureKind.Call);
|
|
10510
10599
|
if (callSignatures.length === 1) {
|
|
10511
10600
|
const [signature] = callSignatures;
|
|
10512
|
-
const returnType =
|
|
10601
|
+
const returnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
10513
10602
|
const maybeLayer = yield* option(typeParser.layerType(returnType, node));
|
|
10514
10603
|
if (isSome2(maybeLayer)) {
|
|
10515
|
-
const { allIndexes: outTypes } = yield* appendToUniqueTypesMap(
|
|
10604
|
+
const { allIndexes: outTypes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
10516
10605
|
ctx.services,
|
|
10517
10606
|
maybeLayer.value.ROut,
|
|
10518
10607
|
excludeNever
|
|
10519
10608
|
);
|
|
10520
|
-
const { allIndexes: inTypes } = yield* appendToUniqueTypesMap(
|
|
10609
|
+
const { allIndexes: inTypes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
10521
10610
|
ctx.services,
|
|
10522
10611
|
maybeLayer.value.RIn,
|
|
10523
10612
|
excludeNever
|
|
@@ -10562,12 +10651,12 @@ function processLayerGraphNode(ctx, node, pipedInGraphNode) {
|
|
|
10562
10651
|
const type = typeChecker.getTypeAtLocation(node);
|
|
10563
10652
|
const maybeLayer = yield* option(typeParser.layerType(type, node));
|
|
10564
10653
|
if (isSome2(maybeLayer)) {
|
|
10565
|
-
const { allIndexes: outTypes } = yield* appendToUniqueTypesMap(
|
|
10654
|
+
const { allIndexes: outTypes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
10566
10655
|
ctx.services,
|
|
10567
10656
|
maybeLayer.value.ROut,
|
|
10568
10657
|
excludeNever
|
|
10569
10658
|
);
|
|
10570
|
-
const { allIndexes: inTypes } = yield* appendToUniqueTypesMap(
|
|
10659
|
+
const { allIndexes: inTypes } = yield* typeCheckerUtils.appendToUniqueTypesMap(
|
|
10571
10660
|
ctx.services,
|
|
10572
10661
|
maybeLayer.value.RIn,
|
|
10573
10662
|
excludeNever
|
|
@@ -10781,8 +10870,8 @@ function layerInfo(sourceFile, position, quickInfo2) {
|
|
|
10781
10870
|
)
|
|
10782
10871
|
);
|
|
10783
10872
|
if (!quickInfo2) {
|
|
10784
|
-
const start =
|
|
10785
|
-
const end = node.
|
|
10873
|
+
const start = ts.getTokenPosOfNode(node, sourceFile);
|
|
10874
|
+
const end = node.end;
|
|
10786
10875
|
return {
|
|
10787
10876
|
kind: ts.ScriptElementKind.callSignatureElement,
|
|
10788
10877
|
kindModifiers: "",
|
|
@@ -11585,7 +11674,10 @@ var pipeableToDatafirst = createRefactor({
|
|
|
11585
11674
|
if (!ts.isCallExpression(node2)) return none2();
|
|
11586
11675
|
const signature = typeChecker.getResolvedSignature(node2);
|
|
11587
11676
|
if (!signature) return none2();
|
|
11588
|
-
const callSignatures = typeChecker.
|
|
11677
|
+
const callSignatures = typeChecker.getSignaturesOfType(
|
|
11678
|
+
typeChecker.getTypeAtLocation(node2.expression),
|
|
11679
|
+
ts.SignatureKind.Call
|
|
11680
|
+
);
|
|
11589
11681
|
for (let i = 0; i < callSignatures.length; i++) {
|
|
11590
11682
|
const callSignature = callSignatures[i];
|
|
11591
11683
|
if (callSignature.parameters.length === node2.arguments.length + 1) {
|
|
@@ -12545,6 +12637,7 @@ var init = (modules) => {
|
|
|
12545
12637
|
function runNano(program) {
|
|
12546
12638
|
return (fa) => pipe(
|
|
12547
12639
|
fa,
|
|
12640
|
+
nanoLayer3,
|
|
12548
12641
|
nanoLayer2,
|
|
12549
12642
|
nanoLayer,
|
|
12550
12643
|
provideService(TypeCheckerApi, program.getTypeChecker()),
|
|
@@ -12579,7 +12672,7 @@ var init = (modules) => {
|
|
|
12579
12672
|
};
|
|
12580
12673
|
proxy.getSemanticDiagnostics = (fileName, ...args2) => {
|
|
12581
12674
|
const applicableDiagnostics = languageService.getSemanticDiagnostics(fileName, ...args2);
|
|
12582
|
-
return runDiagnosticsAndCacheCodeFixes(fileName)
|
|
12675
|
+
return concatDiagnostics(runDiagnosticsAndCacheCodeFixes(fileName), applicableDiagnostics);
|
|
12583
12676
|
};
|
|
12584
12677
|
proxy.getSupportedCodeFixes = (...args2) => languageService.getSupportedCodeFixes(...args2).concat(
|
|
12585
12678
|
diagnosticsErrorCodes.map((_) => "" + _)
|