@effect/language-service 0.35.0 → 0.35.1
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/cli.js +34 -1
- package/cli.js.map +1 -1
- package/index.js +94 -23
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +34 -1
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -1294,7 +1294,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1294
1294
|
);
|
|
1295
1295
|
if (fnName) {
|
|
1296
1296
|
fnCall = ts.factory.createCallExpression(
|
|
1297
|
-
|
|
1297
|
+
fnCall,
|
|
1298
1298
|
void 0,
|
|
1299
1299
|
[ts.factory.createStringLiteral(fnName.text)]
|
|
1300
1300
|
);
|
|
@@ -1542,6 +1542,38 @@ function makeTypeScriptUtils(ts) {
|
|
|
1542
1542
|
)
|
|
1543
1543
|
);
|
|
1544
1544
|
}
|
|
1545
|
+
function createDataTaggedErrorDeclaration(dataModuleIdentifier, name, fields) {
|
|
1546
|
+
const invokeTaggedError = ts.factory.createCallExpression(
|
|
1547
|
+
ts.factory.createPropertyAccessExpression(
|
|
1548
|
+
ts.factory.createIdentifier(dataModuleIdentifier),
|
|
1549
|
+
"TaggedError"
|
|
1550
|
+
),
|
|
1551
|
+
void 0,
|
|
1552
|
+
[
|
|
1553
|
+
ts.factory.createStringLiteral(name)
|
|
1554
|
+
]
|
|
1555
|
+
);
|
|
1556
|
+
const withTypeFields = ts.factory.createExpressionWithTypeArguments(
|
|
1557
|
+
invokeTaggedError,
|
|
1558
|
+
[
|
|
1559
|
+
ts.factory.createTypeLiteralNode(fields)
|
|
1560
|
+
]
|
|
1561
|
+
);
|
|
1562
|
+
return ts.factory.createClassDeclaration(
|
|
1563
|
+
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
1564
|
+
name,
|
|
1565
|
+
void 0,
|
|
1566
|
+
[
|
|
1567
|
+
ts.factory.createHeritageClause(
|
|
1568
|
+
ts.SyntaxKind.ExtendsKeyword,
|
|
1569
|
+
[
|
|
1570
|
+
withTypeFields
|
|
1571
|
+
]
|
|
1572
|
+
)
|
|
1573
|
+
],
|
|
1574
|
+
[]
|
|
1575
|
+
);
|
|
1576
|
+
}
|
|
1545
1577
|
return {
|
|
1546
1578
|
findNodeAtPositionIncludingTrivia,
|
|
1547
1579
|
parsePackageContentNameAndVersionFromScope,
|
|
@@ -1553,6 +1585,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1553
1585
|
isNodeInRange,
|
|
1554
1586
|
transformAsyncAwaitToEffectFn,
|
|
1555
1587
|
transformAsyncAwaitToEffectGen,
|
|
1588
|
+
createDataTaggedErrorDeclaration,
|
|
1556
1589
|
findImportedModuleIdentifierByPackageAndNameOrBarrel,
|
|
1557
1590
|
simplifyTypeNode,
|
|
1558
1591
|
tryPreserveDeclarationSemantics,
|
|
@@ -10872,19 +10905,31 @@ var asyncAwaitToFnTryPromise = createRefactor({
|
|
|
10872
10905
|
"effect",
|
|
10873
10906
|
"Effect"
|
|
10874
10907
|
) || "Effect";
|
|
10908
|
+
const dataModuleIdentifierName = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
10909
|
+
sourceFile,
|
|
10910
|
+
"effect",
|
|
10911
|
+
"Data"
|
|
10912
|
+
) || "Data";
|
|
10875
10913
|
let errorCount = 0;
|
|
10914
|
+
const errors = [];
|
|
10876
10915
|
function createErrorADT() {
|
|
10877
10916
|
errorCount++;
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
|
|
10881
|
-
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
)
|
|
10885
|
-
)
|
|
10886
|
-
|
|
10887
|
-
|
|
10917
|
+
const errorName = "Error" + errorCount;
|
|
10918
|
+
errors.push(tsUtils.createDataTaggedErrorDeclaration(dataModuleIdentifierName, errorName, [
|
|
10919
|
+
ts.factory.createPropertySignature(
|
|
10920
|
+
void 0,
|
|
10921
|
+
"cause",
|
|
10922
|
+
void 0,
|
|
10923
|
+
ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword)
|
|
10924
|
+
)
|
|
10925
|
+
]));
|
|
10926
|
+
return ts.factory.createNewExpression(
|
|
10927
|
+
ts.factory.createIdentifier(errorName),
|
|
10928
|
+
void 0,
|
|
10929
|
+
[ts.factory.createObjectLiteralExpression([
|
|
10930
|
+
ts.factory.createShorthandPropertyAssignment("cause")
|
|
10931
|
+
])]
|
|
10932
|
+
);
|
|
10888
10933
|
}
|
|
10889
10934
|
const newDeclaration = tsUtils.transformAsyncAwaitToEffectFn(
|
|
10890
10935
|
node,
|
|
@@ -10913,7 +10958,7 @@ var asyncAwaitToFnTryPromise = createRefactor({
|
|
|
10913
10958
|
ts.factory.createArrowFunction(
|
|
10914
10959
|
void 0,
|
|
10915
10960
|
void 0,
|
|
10916
|
-
[ts.factory.createParameterDeclaration(void 0, void 0, "
|
|
10961
|
+
[ts.factory.createParameterDeclaration(void 0, void 0, "cause")],
|
|
10917
10962
|
void 0,
|
|
10918
10963
|
void 0,
|
|
10919
10964
|
createErrorADT()
|
|
@@ -10923,6 +10968,13 @@ var asyncAwaitToFnTryPromise = createRefactor({
|
|
|
10923
10968
|
]
|
|
10924
10969
|
)
|
|
10925
10970
|
);
|
|
10971
|
+
let beforeNode = node;
|
|
10972
|
+
while (beforeNode.parent && !ts.isSourceFile(beforeNode.parent)) {
|
|
10973
|
+
beforeNode = beforeNode.parent;
|
|
10974
|
+
}
|
|
10975
|
+
for (const error of errors) {
|
|
10976
|
+
changeTracker.insertNodeBefore(sourceFile, beforeNode, error, true);
|
|
10977
|
+
}
|
|
10926
10978
|
changeTracker.replaceNode(sourceFile, node, newDeclaration);
|
|
10927
10979
|
}),
|
|
10928
10980
|
provideService(TypeScriptApi, ts),
|
|
@@ -11022,19 +11074,31 @@ var asyncAwaitToGenTryPromise = createRefactor({
|
|
|
11022
11074
|
"effect",
|
|
11023
11075
|
"Effect"
|
|
11024
11076
|
) || "Effect";
|
|
11077
|
+
const dataModuleIdentifierName = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
11078
|
+
sourceFile,
|
|
11079
|
+
"effect",
|
|
11080
|
+
"Data"
|
|
11081
|
+
) || "Data";
|
|
11025
11082
|
let errorCount = 0;
|
|
11083
|
+
const errors = [];
|
|
11026
11084
|
function createErrorADT() {
|
|
11027
11085
|
errorCount++;
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
)
|
|
11035
|
-
)
|
|
11036
|
-
|
|
11037
|
-
|
|
11086
|
+
const errorName = "Error" + errorCount;
|
|
11087
|
+
errors.push(tsUtils.createDataTaggedErrorDeclaration(dataModuleIdentifierName, errorName, [
|
|
11088
|
+
ts.factory.createPropertySignature(
|
|
11089
|
+
void 0,
|
|
11090
|
+
"cause",
|
|
11091
|
+
void 0,
|
|
11092
|
+
ts.factory.createKeywordTypeNode(ts.SyntaxKind.UnknownKeyword)
|
|
11093
|
+
)
|
|
11094
|
+
]));
|
|
11095
|
+
return ts.factory.createNewExpression(
|
|
11096
|
+
ts.factory.createIdentifier(errorName),
|
|
11097
|
+
void 0,
|
|
11098
|
+
[ts.factory.createObjectLiteralExpression([
|
|
11099
|
+
ts.factory.createShorthandPropertyAssignment("cause")
|
|
11100
|
+
])]
|
|
11101
|
+
);
|
|
11038
11102
|
}
|
|
11039
11103
|
const newDeclaration = tsUtils.transformAsyncAwaitToEffectGen(
|
|
11040
11104
|
node,
|
|
@@ -11063,7 +11127,7 @@ var asyncAwaitToGenTryPromise = createRefactor({
|
|
|
11063
11127
|
ts.factory.createArrowFunction(
|
|
11064
11128
|
void 0,
|
|
11065
11129
|
void 0,
|
|
11066
|
-
[ts.factory.createParameterDeclaration(void 0, void 0, "
|
|
11130
|
+
[ts.factory.createParameterDeclaration(void 0, void 0, "cause")],
|
|
11067
11131
|
void 0,
|
|
11068
11132
|
void 0,
|
|
11069
11133
|
createErrorADT()
|
|
@@ -11073,6 +11137,13 @@ var asyncAwaitToGenTryPromise = createRefactor({
|
|
|
11073
11137
|
]
|
|
11074
11138
|
)
|
|
11075
11139
|
);
|
|
11140
|
+
let beforeNode = node;
|
|
11141
|
+
while (beforeNode.parent && !ts.isSourceFile(beforeNode.parent)) {
|
|
11142
|
+
beforeNode = beforeNode.parent;
|
|
11143
|
+
}
|
|
11144
|
+
for (const error of errors) {
|
|
11145
|
+
changeTracker.insertNodeBefore(sourceFile, beforeNode, error, true);
|
|
11146
|
+
}
|
|
11076
11147
|
changeTracker.replaceNode(sourceFile, node, newDeclaration);
|
|
11077
11148
|
}),
|
|
11078
11149
|
provideService(TypeScriptApi, ts),
|