@effect/language-service 0.34.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/README.md +5 -4
- package/cli.js +109 -7
- package/cli.js.map +1 -1
- package/index.js +314 -29
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +134 -52
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -135,9 +135,6 @@ 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.1/node_modules/effect/dist/esm/internal/errors.js
|
|
139
|
-
var getBugErrorMessage = (message) => `BUG: ${message} - please report an issue at https://github.com/Effect-TS/effect/issues`;
|
|
140
|
-
|
|
141
138
|
// node_modules/.pnpm/effect@3.17.1/node_modules/effect/dist/esm/Utils.js
|
|
142
139
|
var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
|
|
143
140
|
var GenKindImpl = class {
|
|
@@ -238,12 +235,6 @@ var YieldWrap = class {
|
|
|
238
235
|
return this.#value;
|
|
239
236
|
}
|
|
240
237
|
};
|
|
241
|
-
function yieldWrapGet(self) {
|
|
242
|
-
if (typeof self === "object" && self !== null && YieldWrapTypeId in self) {
|
|
243
|
-
return self[YieldWrapTypeId]();
|
|
244
|
-
}
|
|
245
|
-
throw new Error(getBugErrorMessage("yieldWrapGet"));
|
|
246
|
-
}
|
|
247
238
|
var structuralRegionState = /* @__PURE__ */ globalValue("effect/Utils/isStructuralRegion", () => ({
|
|
248
239
|
enabled: false,
|
|
249
240
|
tester: void 0
|
|
@@ -748,6 +739,31 @@ var NanoTag = class {
|
|
|
748
739
|
}
|
|
749
740
|
};
|
|
750
741
|
var Tag = (identifier) => new NanoTag(identifier);
|
|
742
|
+
var SingleShotGen2 = class _SingleShotGen {
|
|
743
|
+
called = false;
|
|
744
|
+
self;
|
|
745
|
+
constructor(self) {
|
|
746
|
+
this.self = self;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* @since 2.0.0
|
|
750
|
+
*/
|
|
751
|
+
next(a) {
|
|
752
|
+
return this.called ? {
|
|
753
|
+
value: a,
|
|
754
|
+
done: true
|
|
755
|
+
} : (this.called = true, {
|
|
756
|
+
value: this.self,
|
|
757
|
+
done: false
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* @since 2.0.0
|
|
762
|
+
*/
|
|
763
|
+
[Symbol.iterator]() {
|
|
764
|
+
return new _SingleShotGen(this.self);
|
|
765
|
+
}
|
|
766
|
+
};
|
|
751
767
|
var evaluate = Symbol.for("Nano.evaluate");
|
|
752
768
|
var contA = Symbol.for("Nano.contA");
|
|
753
769
|
var contE = Symbol.for("Nano.contE");
|
|
@@ -762,7 +778,7 @@ var NanoDefectException = class {
|
|
|
762
778
|
};
|
|
763
779
|
var PrimitiveProto = {
|
|
764
780
|
[Symbol.iterator]() {
|
|
765
|
-
return new
|
|
781
|
+
return new SingleShotGen2(this);
|
|
766
782
|
}
|
|
767
783
|
};
|
|
768
784
|
var SucceedProto = {
|
|
@@ -885,7 +901,7 @@ var FromIteratorProto = {
|
|
|
885
901
|
const state = this[args][0].next(value);
|
|
886
902
|
if (state.done) return succeed(state.value);
|
|
887
903
|
fiber._stack.push(this);
|
|
888
|
-
return
|
|
904
|
+
return state.value;
|
|
889
905
|
},
|
|
890
906
|
[evaluate](fiber) {
|
|
891
907
|
return this[contA](this[args][1], fiber);
|
|
@@ -1256,7 +1272,7 @@ function makeTypeScriptUtils(ts) {
|
|
|
1256
1272
|
function isNodeInRange(textRange) {
|
|
1257
1273
|
return (node) => node.pos <= textRange.pos && node.end >= textRange.end;
|
|
1258
1274
|
}
|
|
1259
|
-
function
|
|
1275
|
+
function transformAsyncAwaitToEffectGeneratorBody(body, onAwait) {
|
|
1260
1276
|
function visitor(_) {
|
|
1261
1277
|
if (ts.isAwaitExpression(_)) {
|
|
1262
1278
|
const expression = ts.visitEachChild(_.expression, visitor, ts.nullTransformationContext);
|
|
@@ -1267,7 +1283,44 @@ function makeTypeScriptUtils(ts) {
|
|
|
1267
1283
|
}
|
|
1268
1284
|
return ts.visitEachChild(_, visitor, ts.nullTransformationContext);
|
|
1269
1285
|
}
|
|
1270
|
-
|
|
1286
|
+
return visitor(body);
|
|
1287
|
+
}
|
|
1288
|
+
function transformAsyncAwaitToEffectFn(node, effectModuleName, onAwait) {
|
|
1289
|
+
const generatorBody = transformAsyncAwaitToEffectGeneratorBody(node.body, onAwait);
|
|
1290
|
+
const fnName = node.name && ts.isIdentifier(node.name) ? node.name : ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name) && node.parent.initializer === node ? node.parent.name : void 0;
|
|
1291
|
+
let fnCall = ts.factory.createPropertyAccessExpression(
|
|
1292
|
+
ts.factory.createIdentifier(effectModuleName),
|
|
1293
|
+
"fn"
|
|
1294
|
+
);
|
|
1295
|
+
if (fnName) {
|
|
1296
|
+
fnCall = ts.factory.createCallExpression(
|
|
1297
|
+
fnCall,
|
|
1298
|
+
void 0,
|
|
1299
|
+
[ts.factory.createStringLiteral(fnName.text)]
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
return tryPreserveDeclarationSemantics(
|
|
1303
|
+
node,
|
|
1304
|
+
ts.factory.createCallExpression(
|
|
1305
|
+
fnCall,
|
|
1306
|
+
void 0,
|
|
1307
|
+
[
|
|
1308
|
+
ts.factory.createFunctionExpression(
|
|
1309
|
+
void 0,
|
|
1310
|
+
ts.factory.createToken(ts.SyntaxKind.AsteriskToken),
|
|
1311
|
+
void 0,
|
|
1312
|
+
node.typeParameters,
|
|
1313
|
+
node.parameters,
|
|
1314
|
+
void 0,
|
|
1315
|
+
ts.isBlock(generatorBody) ? generatorBody : ts.factory.createBlock([ts.factory.createReturnStatement(generatorBody)])
|
|
1316
|
+
)
|
|
1317
|
+
]
|
|
1318
|
+
),
|
|
1319
|
+
true
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
function transformAsyncAwaitToEffectGen(node, effectModuleName, onAwait) {
|
|
1323
|
+
const generatorBody = transformAsyncAwaitToEffectGeneratorBody(node.body, onAwait);
|
|
1271
1324
|
const effectGenCallExp = createEffectGenCallExpression(effectModuleName, generatorBody);
|
|
1272
1325
|
let currentFlags = ts.getCombinedModifierFlags(node);
|
|
1273
1326
|
currentFlags &= ~ts.ModifierFlags.Async;
|
|
@@ -1371,12 +1424,15 @@ function makeTypeScriptUtils(ts) {
|
|
|
1371
1424
|
}
|
|
1372
1425
|
return typeNode;
|
|
1373
1426
|
}
|
|
1374
|
-
function tryPreserveDeclarationSemantics(nodeToReplace, node) {
|
|
1427
|
+
function tryPreserveDeclarationSemantics(nodeToReplace, node, dropAsync) {
|
|
1375
1428
|
if (!ts.isExpression(node)) return node;
|
|
1376
1429
|
if (ts.isFunctionDeclaration(nodeToReplace)) {
|
|
1377
1430
|
if (!nodeToReplace.name) return node;
|
|
1431
|
+
let currentFlags = ts.getCombinedModifierFlags(nodeToReplace);
|
|
1432
|
+
currentFlags &= ~ts.ModifierFlags.Async;
|
|
1433
|
+
const newModifiers = dropAsync ? ts.factory.createModifiersFromModifierFlags(currentFlags) : nodeToReplace.modifiers;
|
|
1378
1434
|
return ts.factory.createVariableStatement(
|
|
1379
|
-
|
|
1435
|
+
newModifiers,
|
|
1380
1436
|
ts.factory.createVariableDeclarationList(
|
|
1381
1437
|
[ts.factory.createVariableDeclaration(
|
|
1382
1438
|
nodeToReplace.name,
|
|
@@ -1388,8 +1444,11 @@ function makeTypeScriptUtils(ts) {
|
|
|
1388
1444
|
)
|
|
1389
1445
|
);
|
|
1390
1446
|
} else if (ts.isMethodDeclaration(nodeToReplace)) {
|
|
1447
|
+
let currentFlags = ts.getCombinedModifierFlags(nodeToReplace);
|
|
1448
|
+
currentFlags &= ~ts.ModifierFlags.Async;
|
|
1449
|
+
const newModifiers = dropAsync ? ts.factory.createModifiersFromModifierFlags(currentFlags) : nodeToReplace.modifiers;
|
|
1391
1450
|
return ts.factory.createPropertyDeclaration(
|
|
1392
|
-
|
|
1451
|
+
newModifiers,
|
|
1393
1452
|
nodeToReplace.name,
|
|
1394
1453
|
void 0,
|
|
1395
1454
|
void 0,
|
|
@@ -1483,6 +1542,38 @@ function makeTypeScriptUtils(ts) {
|
|
|
1483
1542
|
)
|
|
1484
1543
|
);
|
|
1485
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
|
+
}
|
|
1486
1577
|
return {
|
|
1487
1578
|
findNodeAtPositionIncludingTrivia,
|
|
1488
1579
|
parsePackageContentNameAndVersionFromScope,
|
|
@@ -1492,7 +1583,9 @@ function makeTypeScriptUtils(ts) {
|
|
|
1492
1583
|
getAncestorNodesInRange,
|
|
1493
1584
|
toTextRange,
|
|
1494
1585
|
isNodeInRange,
|
|
1586
|
+
transformAsyncAwaitToEffectFn,
|
|
1495
1587
|
transformAsyncAwaitToEffectGen,
|
|
1588
|
+
createDataTaggedErrorDeclaration,
|
|
1496
1589
|
findImportedModuleIdentifierByPackageAndNameOrBarrel,
|
|
1497
1590
|
simplifyTypeNode,
|
|
1498
1591
|
tryPreserveDeclarationSemantics,
|
|
@@ -10722,6 +10815,175 @@ function quickInfo(sourceFile, position, quickInfo2) {
|
|
|
10722
10815
|
});
|
|
10723
10816
|
}
|
|
10724
10817
|
|
|
10818
|
+
// src/refactors/asyncAwaitToFn.ts
|
|
10819
|
+
var asyncAwaitToFn = createRefactor({
|
|
10820
|
+
name: "asyncAwaitToFn",
|
|
10821
|
+
description: "Convert to Effect.fn",
|
|
10822
|
+
apply: fn("asyncAwaitToFn.apply")(function* (sourceFile, textRange) {
|
|
10823
|
+
const ts = yield* service(TypeScriptApi);
|
|
10824
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
10825
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
10826
|
+
const maybeNode = pipe(
|
|
10827
|
+
tsUtils.getAncestorNodesInRange(sourceFile, textRange),
|
|
10828
|
+
filter(
|
|
10829
|
+
(node2) => ts.isFunctionDeclaration(node2) || ts.isArrowFunction(node2) || ts.isFunctionExpression(node2)
|
|
10830
|
+
),
|
|
10831
|
+
filter((node2) => !!node2.body),
|
|
10832
|
+
filter((node2) => !!(ts.getCombinedModifierFlags(node2) & ts.ModifierFlags.Async)),
|
|
10833
|
+
head
|
|
10834
|
+
);
|
|
10835
|
+
if (isNone2(maybeNode)) return yield* fail(new RefactorNotApplicableError());
|
|
10836
|
+
const node = maybeNode.value;
|
|
10837
|
+
return {
|
|
10838
|
+
kind: "refactor.rewrite.effect.asyncAwaitToFn",
|
|
10839
|
+
description: "Rewrite to Effect.fn",
|
|
10840
|
+
apply: pipe(
|
|
10841
|
+
gen(function* () {
|
|
10842
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
10843
|
+
const effectModuleIdentifierName = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
10844
|
+
sourceFile,
|
|
10845
|
+
"effect",
|
|
10846
|
+
"Effect"
|
|
10847
|
+
) || "Effect";
|
|
10848
|
+
const newDeclaration = tsUtils.transformAsyncAwaitToEffectFn(
|
|
10849
|
+
node,
|
|
10850
|
+
effectModuleIdentifierName,
|
|
10851
|
+
(expression) => ts.factory.createCallExpression(
|
|
10852
|
+
ts.factory.createPropertyAccessExpression(
|
|
10853
|
+
ts.factory.createIdentifier(effectModuleIdentifierName),
|
|
10854
|
+
"promise"
|
|
10855
|
+
),
|
|
10856
|
+
void 0,
|
|
10857
|
+
[
|
|
10858
|
+
ts.factory.createArrowFunction(
|
|
10859
|
+
void 0,
|
|
10860
|
+
void 0,
|
|
10861
|
+
[],
|
|
10862
|
+
void 0,
|
|
10863
|
+
void 0,
|
|
10864
|
+
expression
|
|
10865
|
+
)
|
|
10866
|
+
]
|
|
10867
|
+
)
|
|
10868
|
+
);
|
|
10869
|
+
changeTracker.replaceNode(sourceFile, node, newDeclaration);
|
|
10870
|
+
}),
|
|
10871
|
+
provideService(TypeScriptApi, ts),
|
|
10872
|
+
provideService(TypeCheckerApi, typeChecker)
|
|
10873
|
+
)
|
|
10874
|
+
};
|
|
10875
|
+
})
|
|
10876
|
+
});
|
|
10877
|
+
|
|
10878
|
+
// src/refactors/asyncAwaitToFnTryPromise.ts
|
|
10879
|
+
var asyncAwaitToFnTryPromise = createRefactor({
|
|
10880
|
+
name: "asyncAwaitToFnTryPromise",
|
|
10881
|
+
description: "Convert to Effect.fn with failures",
|
|
10882
|
+
apply: fn("asyncAwaitToFnTryPromise.apply")(function* (sourceFile, textRange) {
|
|
10883
|
+
const ts = yield* service(TypeScriptApi);
|
|
10884
|
+
const tsUtils = yield* service(TypeScriptUtils);
|
|
10885
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
10886
|
+
const maybeNode = pipe(
|
|
10887
|
+
tsUtils.getAncestorNodesInRange(sourceFile, textRange),
|
|
10888
|
+
filter(
|
|
10889
|
+
(node2) => ts.isFunctionDeclaration(node2) || ts.isArrowFunction(node2) || ts.isFunctionExpression(node2)
|
|
10890
|
+
),
|
|
10891
|
+
filter((node2) => !!node2.body),
|
|
10892
|
+
filter((node2) => !!(ts.getCombinedModifierFlags(node2) & ts.ModifierFlags.Async)),
|
|
10893
|
+
head
|
|
10894
|
+
);
|
|
10895
|
+
if (isNone2(maybeNode)) return yield* fail(new RefactorNotApplicableError());
|
|
10896
|
+
const node = maybeNode.value;
|
|
10897
|
+
return {
|
|
10898
|
+
kind: "refactor.rewrite.effect.asyncAwaitToFnTryPromise",
|
|
10899
|
+
description: "Rewrite to Effect.fn with failures",
|
|
10900
|
+
apply: pipe(
|
|
10901
|
+
gen(function* () {
|
|
10902
|
+
const changeTracker = yield* service(ChangeTracker);
|
|
10903
|
+
const effectModuleIdentifierName = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
10904
|
+
sourceFile,
|
|
10905
|
+
"effect",
|
|
10906
|
+
"Effect"
|
|
10907
|
+
) || "Effect";
|
|
10908
|
+
const dataModuleIdentifierName = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
10909
|
+
sourceFile,
|
|
10910
|
+
"effect",
|
|
10911
|
+
"Data"
|
|
10912
|
+
) || "Data";
|
|
10913
|
+
let errorCount = 0;
|
|
10914
|
+
const errors = [];
|
|
10915
|
+
function createErrorADT() {
|
|
10916
|
+
errorCount++;
|
|
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
|
+
);
|
|
10933
|
+
}
|
|
10934
|
+
const newDeclaration = tsUtils.transformAsyncAwaitToEffectFn(
|
|
10935
|
+
node,
|
|
10936
|
+
effectModuleIdentifierName,
|
|
10937
|
+
(expression) => ts.factory.createCallExpression(
|
|
10938
|
+
ts.factory.createPropertyAccessExpression(
|
|
10939
|
+
ts.factory.createIdentifier(effectModuleIdentifierName),
|
|
10940
|
+
"tryPromise"
|
|
10941
|
+
),
|
|
10942
|
+
void 0,
|
|
10943
|
+
[
|
|
10944
|
+
ts.factory.createObjectLiteralExpression([
|
|
10945
|
+
ts.factory.createPropertyAssignment(
|
|
10946
|
+
ts.factory.createIdentifier("try"),
|
|
10947
|
+
ts.factory.createArrowFunction(
|
|
10948
|
+
void 0,
|
|
10949
|
+
void 0,
|
|
10950
|
+
[],
|
|
10951
|
+
void 0,
|
|
10952
|
+
void 0,
|
|
10953
|
+
expression
|
|
10954
|
+
)
|
|
10955
|
+
),
|
|
10956
|
+
ts.factory.createPropertyAssignment(
|
|
10957
|
+
ts.factory.createIdentifier("catch"),
|
|
10958
|
+
ts.factory.createArrowFunction(
|
|
10959
|
+
void 0,
|
|
10960
|
+
void 0,
|
|
10961
|
+
[ts.factory.createParameterDeclaration(void 0, void 0, "cause")],
|
|
10962
|
+
void 0,
|
|
10963
|
+
void 0,
|
|
10964
|
+
createErrorADT()
|
|
10965
|
+
)
|
|
10966
|
+
)
|
|
10967
|
+
])
|
|
10968
|
+
]
|
|
10969
|
+
)
|
|
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
|
+
}
|
|
10978
|
+
changeTracker.replaceNode(sourceFile, node, newDeclaration);
|
|
10979
|
+
}),
|
|
10980
|
+
provideService(TypeScriptApi, ts),
|
|
10981
|
+
provideService(TypeCheckerApi, typeChecker)
|
|
10982
|
+
)
|
|
10983
|
+
};
|
|
10984
|
+
})
|
|
10985
|
+
});
|
|
10986
|
+
|
|
10725
10987
|
// src/refactors/asyncAwaitToGen.ts
|
|
10726
10988
|
var asyncAwaitToGen = createRefactor({
|
|
10727
10989
|
name: "asyncAwaitToGen",
|
|
@@ -10812,19 +11074,31 @@ var asyncAwaitToGenTryPromise = createRefactor({
|
|
|
10812
11074
|
"effect",
|
|
10813
11075
|
"Effect"
|
|
10814
11076
|
) || "Effect";
|
|
11077
|
+
const dataModuleIdentifierName = tsUtils.findImportedModuleIdentifierByPackageAndNameOrBarrel(
|
|
11078
|
+
sourceFile,
|
|
11079
|
+
"effect",
|
|
11080
|
+
"Data"
|
|
11081
|
+
) || "Data";
|
|
10815
11082
|
let errorCount = 0;
|
|
11083
|
+
const errors = [];
|
|
10816
11084
|
function createErrorADT() {
|
|
10817
11085
|
errorCount++;
|
|
10818
|
-
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
|
|
10824
|
-
)
|
|
10825
|
-
)
|
|
10826
|
-
|
|
10827
|
-
|
|
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
|
+
);
|
|
10828
11102
|
}
|
|
10829
11103
|
const newDeclaration = tsUtils.transformAsyncAwaitToEffectGen(
|
|
10830
11104
|
node,
|
|
@@ -10853,7 +11127,7 @@ var asyncAwaitToGenTryPromise = createRefactor({
|
|
|
10853
11127
|
ts.factory.createArrowFunction(
|
|
10854
11128
|
void 0,
|
|
10855
11129
|
void 0,
|
|
10856
|
-
[ts.factory.createParameterDeclaration(void 0, void 0, "
|
|
11130
|
+
[ts.factory.createParameterDeclaration(void 0, void 0, "cause")],
|
|
10857
11131
|
void 0,
|
|
10858
11132
|
void 0,
|
|
10859
11133
|
createErrorADT()
|
|
@@ -10863,6 +11137,13 @@ var asyncAwaitToGenTryPromise = createRefactor({
|
|
|
10863
11137
|
]
|
|
10864
11138
|
)
|
|
10865
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
|
+
}
|
|
10866
11147
|
changeTracker.replaceNode(sourceFile, node, newDeclaration);
|
|
10867
11148
|
}),
|
|
10868
11149
|
provideService(TypeScriptApi, ts),
|
|
@@ -10902,6 +11183,7 @@ var effectGenToFn = createRefactor({
|
|
|
10902
11183
|
const nodesFromInitializers = pipe(
|
|
10903
11184
|
parentNodes,
|
|
10904
11185
|
filter((_) => ts.isVariableDeclaration(_) && _.initializer ? true : false),
|
|
11186
|
+
filter((_) => tsUtils.isNodeInRange(textRange)(_.name)),
|
|
10905
11187
|
map4((_) => _.initializer)
|
|
10906
11188
|
);
|
|
10907
11189
|
const maybeNode = yield* pipe(
|
|
@@ -10945,7 +11227,7 @@ var effectGenToFn = createRefactor({
|
|
|
10945
11227
|
changeTracker.replaceNode(
|
|
10946
11228
|
sourceFile,
|
|
10947
11229
|
nodeToReplace,
|
|
10948
|
-
tsUtils.tryPreserveDeclarationSemantics(nodeToReplace, effectFnCallWithGenerator)
|
|
11230
|
+
tsUtils.tryPreserveDeclarationSemantics(nodeToReplace, effectFnCallWithGenerator, false)
|
|
10949
11231
|
);
|
|
10950
11232
|
}),
|
|
10951
11233
|
provideService(TypeScriptApi, ts)
|
|
@@ -10998,7 +11280,8 @@ var functionToArrow = createRefactor({
|
|
|
10998
11280
|
);
|
|
10999
11281
|
const newDeclaration = tsUtils.tryPreserveDeclarationSemantics(
|
|
11000
11282
|
node,
|
|
11001
|
-
arrowFunction
|
|
11283
|
+
arrowFunction,
|
|
11284
|
+
false
|
|
11002
11285
|
);
|
|
11003
11286
|
changeTracker.replaceNode(sourceFile, node, newDeclaration, {
|
|
11004
11287
|
leadingTriviaOption: ts.textChanges.LeadingTriviaOption.IncludeAll,
|
|
@@ -12214,6 +12497,8 @@ var wrapWithPipe = createRefactor({
|
|
|
12214
12497
|
var refactors = [
|
|
12215
12498
|
asyncAwaitToGen,
|
|
12216
12499
|
asyncAwaitToGenTryPromise,
|
|
12500
|
+
asyncAwaitToFn,
|
|
12501
|
+
asyncAwaitToFnTryPromise,
|
|
12217
12502
|
functionToArrow,
|
|
12218
12503
|
typeToEffectSchema,
|
|
12219
12504
|
typeToEffectSchemaClass,
|