@effect/language-service 0.53.2 → 0.54.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 +1 -0
- package/cli.js +74 -4
- package/cli.js.map +1 -1
- package/effect-lsp-patch-utils.js +67 -10
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +59 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +59 -1
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -8291,6 +8291,63 @@ var tryCatchInEffectGen = createDiagnostic({
|
|
|
8291
8291
|
})
|
|
8292
8292
|
});
|
|
8293
8293
|
|
|
8294
|
+
// src/diagnostics/unknownInEffectCatch.ts
|
|
8295
|
+
var unknownInEffectCatch = createDiagnostic({
|
|
8296
|
+
name: "unknownInEffectCatch",
|
|
8297
|
+
code: 31,
|
|
8298
|
+
severity: "warning",
|
|
8299
|
+
apply: fn("unknownInEffectCatch.apply")(function* (sourceFile, report) {
|
|
8300
|
+
const ts = yield* service(TypeScriptApi);
|
|
8301
|
+
const typeParser = yield* service(TypeParser);
|
|
8302
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
8303
|
+
const nodeToVisit = [];
|
|
8304
|
+
const appendNodeToVisit = (node) => {
|
|
8305
|
+
nodeToVisit.push(node);
|
|
8306
|
+
return void 0;
|
|
8307
|
+
};
|
|
8308
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
8309
|
+
while (nodeToVisit.length > 0) {
|
|
8310
|
+
const node = nodeToVisit.shift();
|
|
8311
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
8312
|
+
if (ts.isCallExpression(node)) {
|
|
8313
|
+
const isEffectWithCatch = yield* pipe(
|
|
8314
|
+
typeParser.isNodeReferenceToEffectModuleApi("tryPromise")(node.expression),
|
|
8315
|
+
orElse2(() => typeParser.isNodeReferenceToEffectModuleApi("try")(node.expression)),
|
|
8316
|
+
orElse2(() => typeParser.isNodeReferenceToEffectModuleApi("tryMap")(node.expression)),
|
|
8317
|
+
orElse2(() => typeParser.isNodeReferenceToEffectModuleApi("tryMapPromise")(node.expression)),
|
|
8318
|
+
orElse2(() => void_)
|
|
8319
|
+
);
|
|
8320
|
+
if (isEffectWithCatch) {
|
|
8321
|
+
const signature = typeChecker.getResolvedSignature(node);
|
|
8322
|
+
if (signature) {
|
|
8323
|
+
const objectType = typeChecker.getParameterType(signature, 0);
|
|
8324
|
+
const catchFunctionSymbol = typeChecker.getPropertyOfType(objectType, "catch");
|
|
8325
|
+
if (catchFunctionSymbol) {
|
|
8326
|
+
const catchFunctionType = typeChecker.getTypeOfSymbolAtLocation(catchFunctionSymbol, node);
|
|
8327
|
+
const signatures = typeChecker.getSignaturesOfType(catchFunctionType, ts.SignatureKind.Call);
|
|
8328
|
+
if (signatures.length > 0) {
|
|
8329
|
+
const returnType = typeChecker.getReturnTypeOfSignature(signatures[0]);
|
|
8330
|
+
if (returnType && (returnType.flags & ts.TypeFlags.Unknown || returnType.flags & ts.TypeFlags.Any)) {
|
|
8331
|
+
const nodeText = sourceFile.text.substring(
|
|
8332
|
+
ts.getTokenPosOfNode(node.expression, sourceFile),
|
|
8333
|
+
node.expression.end
|
|
8334
|
+
);
|
|
8335
|
+
report({
|
|
8336
|
+
location: node.expression,
|
|
8337
|
+
messageText: `The 'catch' callback in ${nodeText} returns 'unknown'. The catch callback should be used to provide typed errors.
|
|
8338
|
+
Consider wrapping unknown errors into Effect's Data.TaggedError for example, or narrow down the type to the specific error raised.`,
|
|
8339
|
+
fixes: []
|
|
8340
|
+
});
|
|
8341
|
+
}
|
|
8342
|
+
}
|
|
8343
|
+
}
|
|
8344
|
+
}
|
|
8345
|
+
}
|
|
8346
|
+
}
|
|
8347
|
+
}
|
|
8348
|
+
})
|
|
8349
|
+
});
|
|
8350
|
+
|
|
8294
8351
|
// src/diagnostics/unnecessaryEffectGen.ts
|
|
8295
8352
|
var unnecessaryEffectGen = createDiagnostic({
|
|
8296
8353
|
name: "unnecessaryEffectGen",
|
|
@@ -8538,7 +8595,8 @@ var diagnostics = [
|
|
|
8538
8595
|
nonObjectEffectServiceType,
|
|
8539
8596
|
deterministicKeys,
|
|
8540
8597
|
missedPipeableOpportunity,
|
|
8541
|
-
strictEffectProvide
|
|
8598
|
+
strictEffectProvide,
|
|
8599
|
+
unknownInEffectCatch
|
|
8542
8600
|
];
|
|
8543
8601
|
|
|
8544
8602
|
// src/completions/effectDiagnosticsComment.ts
|