@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/package.json
CHANGED
package/transform.js
CHANGED
|
@@ -2542,6 +2542,47 @@ function make2(ts, typeChecker) {
|
|
|
2542
2542
|
"TypeParser.scopeType",
|
|
2543
2543
|
(type) => type
|
|
2544
2544
|
);
|
|
2545
|
+
const promiseLike = cachedBy(
|
|
2546
|
+
function(type, atLocation) {
|
|
2547
|
+
const thenProperty = type.getProperty("then");
|
|
2548
|
+
if (!thenProperty) return typeParserIssue("not a promise - missing then property", type, atLocation);
|
|
2549
|
+
const thenType = typeChecker.getTypeOfSymbolAtLocation(thenProperty, atLocation);
|
|
2550
|
+
if (!thenType) return typeParserIssue("not a promise - missing then property", type, atLocation);
|
|
2551
|
+
for (const callSignature of thenType.getCallSignatures()) {
|
|
2552
|
+
const parameter = callSignature.parameters[0];
|
|
2553
|
+
if (!parameter) continue;
|
|
2554
|
+
const parameterType = callSignature.getTypeParameterAtPosition(0);
|
|
2555
|
+
if (!parameterType) continue;
|
|
2556
|
+
let callbackCallSignatures = [];
|
|
2557
|
+
let toTest = [parameterType];
|
|
2558
|
+
while (toTest.length > 0) {
|
|
2559
|
+
const type2 = toTest.shift();
|
|
2560
|
+
if (!type2) continue;
|
|
2561
|
+
const callSignatures = type2.getCallSignatures();
|
|
2562
|
+
callbackCallSignatures = callbackCallSignatures.concat(callSignatures);
|
|
2563
|
+
if (type2.isUnion()) {
|
|
2564
|
+
toTest = toTest.concat(type2.types);
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
for (const callableType of callbackCallSignatures) {
|
|
2568
|
+
const callbackParameter = callableType.parameters[0];
|
|
2569
|
+
if (!callbackParameter) {
|
|
2570
|
+
continue;
|
|
2571
|
+
}
|
|
2572
|
+
const callbackParameterType = callableType.getTypeParameterAtPosition(0);
|
|
2573
|
+
if (!callbackParameterType) {
|
|
2574
|
+
continue;
|
|
2575
|
+
}
|
|
2576
|
+
return succeed({
|
|
2577
|
+
type: callbackParameterType
|
|
2578
|
+
});
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
return typeParserIssue("not a promise", type, atLocation);
|
|
2582
|
+
},
|
|
2583
|
+
"TypeParser.promiseLike",
|
|
2584
|
+
(type) => type
|
|
2585
|
+
);
|
|
2545
2586
|
return {
|
|
2546
2587
|
effectType,
|
|
2547
2588
|
strictEffectType,
|
|
@@ -2557,7 +2598,8 @@ function make2(ts, typeChecker) {
|
|
|
2557
2598
|
contextTag,
|
|
2558
2599
|
pipeableType,
|
|
2559
2600
|
pipeCall,
|
|
2560
|
-
scopeType
|
|
2601
|
+
scopeType,
|
|
2602
|
+
promiseLike
|
|
2561
2603
|
};
|
|
2562
2604
|
}
|
|
2563
2605
|
|