@effect/language-service 0.28.0 → 0.28.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 +1 -0
- package/cli.js +43 -1
- package/cli.js.map +1 -1
- package/index.js +312 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +43 -1
- package/transform.js.map +1 -1
package/README.md
CHANGED
|
@@ -65,6 +65,7 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
|
|
|
65
65
|
- Transform an async function definition, into an Effect by using Effect.gen.
|
|
66
66
|
- Transform an async function definition, into an Effect by using Effect.gen, and generating a tagged error for each promise call.
|
|
67
67
|
- Transform a function returning an Effect.gen into a Effect.fn
|
|
68
|
+
- Implement Service accessors in an `Effect.Service` or `Context.Tag` declaration
|
|
68
69
|
- Function calls to pipe: Transform a set of function calls to a pipe() call.
|
|
69
70
|
- Pipe to datafirst: Transform a pipe() call into a series of datafirst function calls (where available).
|
|
70
71
|
- Toggle return type signature: With a single refactor, adds or removes type annotations from the definition.
|
package/cli.js
CHANGED
|
@@ -31471,6 +31471,47 @@ function make62(ts2, typeChecker) {
|
|
|
31471
31471
|
"TypeParser.scopeType",
|
|
31472
31472
|
(type2) => type2
|
|
31473
31473
|
);
|
|
31474
|
+
const promiseLike = cachedBy(
|
|
31475
|
+
function(type2, atLocation) {
|
|
31476
|
+
const thenProperty = type2.getProperty("then");
|
|
31477
|
+
if (!thenProperty) return typeParserIssue("not a promise - missing then property", type2, atLocation);
|
|
31478
|
+
const thenType = typeChecker.getTypeOfSymbolAtLocation(thenProperty, atLocation);
|
|
31479
|
+
if (!thenType) return typeParserIssue("not a promise - missing then property", type2, atLocation);
|
|
31480
|
+
for (const callSignature of thenType.getCallSignatures()) {
|
|
31481
|
+
const parameter = callSignature.parameters[0];
|
|
31482
|
+
if (!parameter) continue;
|
|
31483
|
+
const parameterType = callSignature.getTypeParameterAtPosition(0);
|
|
31484
|
+
if (!parameterType) continue;
|
|
31485
|
+
let callbackCallSignatures = [];
|
|
31486
|
+
let toTest = [parameterType];
|
|
31487
|
+
while (toTest.length > 0) {
|
|
31488
|
+
const type3 = toTest.shift();
|
|
31489
|
+
if (!type3) continue;
|
|
31490
|
+
const callSignatures = type3.getCallSignatures();
|
|
31491
|
+
callbackCallSignatures = callbackCallSignatures.concat(callSignatures);
|
|
31492
|
+
if (type3.isUnion()) {
|
|
31493
|
+
toTest = toTest.concat(type3.types);
|
|
31494
|
+
}
|
|
31495
|
+
}
|
|
31496
|
+
for (const callableType of callbackCallSignatures) {
|
|
31497
|
+
const callbackParameter = callableType.parameters[0];
|
|
31498
|
+
if (!callbackParameter) {
|
|
31499
|
+
continue;
|
|
31500
|
+
}
|
|
31501
|
+
const callbackParameterType = callableType.getTypeParameterAtPosition(0);
|
|
31502
|
+
if (!callbackParameterType) {
|
|
31503
|
+
continue;
|
|
31504
|
+
}
|
|
31505
|
+
return succeed17({
|
|
31506
|
+
type: callbackParameterType
|
|
31507
|
+
});
|
|
31508
|
+
}
|
|
31509
|
+
}
|
|
31510
|
+
return typeParserIssue("not a promise", type2, atLocation);
|
|
31511
|
+
},
|
|
31512
|
+
"TypeParser.promiseLike",
|
|
31513
|
+
(type2) => type2
|
|
31514
|
+
);
|
|
31474
31515
|
return {
|
|
31475
31516
|
effectType,
|
|
31476
31517
|
strictEffectType,
|
|
@@ -31486,7 +31527,8 @@ function make62(ts2, typeChecker) {
|
|
|
31486
31527
|
contextTag,
|
|
31487
31528
|
pipeableType,
|
|
31488
31529
|
pipeCall,
|
|
31489
|
-
scopeType
|
|
31530
|
+
scopeType,
|
|
31531
|
+
promiseLike
|
|
31490
31532
|
};
|
|
31491
31533
|
}
|
|
31492
31534
|
|