@effect/language-service 0.40.1 → 0.41.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/effect-lsp-patch-utils.js +93 -2
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +93 -2
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +93 -2
- package/transform.js.map +1 -1
package/index.js
CHANGED
|
@@ -4585,7 +4585,7 @@ var missingEffectError = createDiagnostic({
|
|
|
4585
4585
|
// src/diagnostics/missingEffectServiceDependency.ts
|
|
4586
4586
|
var missingEffectServiceDependency = createDiagnostic({
|
|
4587
4587
|
name: "missingEffectServiceDependency",
|
|
4588
|
-
code:
|
|
4588
|
+
code: 22,
|
|
4589
4589
|
severity: "off",
|
|
4590
4590
|
apply: fn("missingEffectServiceDependency.apply")(function* (sourceFile, report) {
|
|
4591
4591
|
const ts = yield* service(TypeScriptApi);
|
|
@@ -4907,6 +4907,96 @@ var multipleEffectProvide = createDiagnostic({
|
|
|
4907
4907
|
})
|
|
4908
4908
|
});
|
|
4909
4909
|
|
|
4910
|
+
// src/diagnostics/nonObjectEffectServiceType.ts
|
|
4911
|
+
var nonObjectEffectServiceType = createDiagnostic({
|
|
4912
|
+
name: "nonObjectEffectServiceType",
|
|
4913
|
+
code: 24,
|
|
4914
|
+
severity: "error",
|
|
4915
|
+
apply: fn("nonObjectEffectServiceType.apply")(function* (sourceFile, report) {
|
|
4916
|
+
const ts = yield* service(TypeScriptApi);
|
|
4917
|
+
const typeChecker = yield* service(TypeCheckerApi);
|
|
4918
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
4919
|
+
const typeParser = yield* service(TypeParser);
|
|
4920
|
+
function isPrimitiveType(type) {
|
|
4921
|
+
return typeCheckerUtils.unrollUnionMembers(type).some(
|
|
4922
|
+
(type2) => !!(type2.flags & ts.TypeFlags.String || type2.flags & ts.TypeFlags.Number || type2.flags & ts.TypeFlags.Boolean || type2.flags & ts.TypeFlags.StringLiteral || type2.flags & ts.TypeFlags.NumberLiteral || type2.flags & ts.TypeFlags.BooleanLiteral || type2.flags & ts.TypeFlags.Undefined || type2.flags & ts.TypeFlags.Null)
|
|
4923
|
+
);
|
|
4924
|
+
}
|
|
4925
|
+
const nodeToVisit = [];
|
|
4926
|
+
const appendNodeToVisit = (node) => {
|
|
4927
|
+
nodeToVisit.push(node);
|
|
4928
|
+
return void 0;
|
|
4929
|
+
};
|
|
4930
|
+
ts.forEachChild(sourceFile, appendNodeToVisit);
|
|
4931
|
+
while (nodeToVisit.length > 0) {
|
|
4932
|
+
const node = nodeToVisit.shift();
|
|
4933
|
+
if (ts.isClassDeclaration(node) && node.name && node.heritageClauses) {
|
|
4934
|
+
const serviceResult = yield* pipe(
|
|
4935
|
+
typeParser.extendsEffectService(node),
|
|
4936
|
+
orElse2(() => void_)
|
|
4937
|
+
);
|
|
4938
|
+
if (serviceResult && serviceResult.options && ts.isObjectLiteralExpression(serviceResult.options)) {
|
|
4939
|
+
const options = serviceResult.options;
|
|
4940
|
+
for (const property of options.properties) {
|
|
4941
|
+
if (!ts.isPropertyAssignment(property) || !ts.isIdentifier(property.name)) {
|
|
4942
|
+
continue;
|
|
4943
|
+
}
|
|
4944
|
+
const propertyName = ts.idText(property.name);
|
|
4945
|
+
const propertyValue = property.initializer;
|
|
4946
|
+
const errorToReport = {
|
|
4947
|
+
location: property.name,
|
|
4948
|
+
messageText: "Effect.Service requires the service type to be an object {} and not a primitive type. \nConsider wrapping the value in an object, or manually using Context.Tag or Effect.Tag if you want to use a primitive instead.",
|
|
4949
|
+
fixes: []
|
|
4950
|
+
};
|
|
4951
|
+
if (propertyName === "succeed") {
|
|
4952
|
+
const valueType = typeChecker.getTypeAtLocation(propertyValue);
|
|
4953
|
+
if (isPrimitiveType(valueType)) {
|
|
4954
|
+
report(errorToReport);
|
|
4955
|
+
}
|
|
4956
|
+
} else if (propertyName === "sync") {
|
|
4957
|
+
const valueType = typeChecker.getTypeAtLocation(propertyValue);
|
|
4958
|
+
const signatures = typeChecker.getSignaturesOfType(valueType, ts.SignatureKind.Call);
|
|
4959
|
+
for (const signature of signatures) {
|
|
4960
|
+
const returnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
4961
|
+
if (isPrimitiveType(returnType)) {
|
|
4962
|
+
report(errorToReport);
|
|
4963
|
+
break;
|
|
4964
|
+
}
|
|
4965
|
+
}
|
|
4966
|
+
} else if (propertyName === "effect" || propertyName === "scoped") {
|
|
4967
|
+
const valueType = typeChecker.getTypeAtLocation(propertyValue);
|
|
4968
|
+
const effectResult = yield* pipe(
|
|
4969
|
+
typeParser.effectType(valueType, propertyValue),
|
|
4970
|
+
orElse2(() => void_)
|
|
4971
|
+
);
|
|
4972
|
+
if (effectResult) {
|
|
4973
|
+
if (isPrimitiveType(effectResult.A)) {
|
|
4974
|
+
report(errorToReport);
|
|
4975
|
+
continue;
|
|
4976
|
+
}
|
|
4977
|
+
} else {
|
|
4978
|
+
const signatures = typeChecker.getSignaturesOfType(valueType, ts.SignatureKind.Call);
|
|
4979
|
+
for (const signature of signatures) {
|
|
4980
|
+
const returnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
4981
|
+
const effectReturnResult = yield* pipe(
|
|
4982
|
+
typeParser.effectType(returnType, propertyValue),
|
|
4983
|
+
orElse2(() => void_)
|
|
4984
|
+
);
|
|
4985
|
+
if (effectReturnResult && isPrimitiveType(effectReturnResult.A)) {
|
|
4986
|
+
report(errorToReport);
|
|
4987
|
+
break;
|
|
4988
|
+
}
|
|
4989
|
+
}
|
|
4990
|
+
}
|
|
4991
|
+
}
|
|
4992
|
+
}
|
|
4993
|
+
}
|
|
4994
|
+
}
|
|
4995
|
+
ts.forEachChild(node, appendNodeToVisit);
|
|
4996
|
+
}
|
|
4997
|
+
})
|
|
4998
|
+
});
|
|
4999
|
+
|
|
4910
5000
|
// src/diagnostics/outdatedEffectCodegen.ts
|
|
4911
5001
|
var outdatedEffectCodegen = createDiagnostic({
|
|
4912
5002
|
name: "outdatedEffectCodegen",
|
|
@@ -5527,7 +5617,8 @@ var diagnostics = [
|
|
|
5527
5617
|
multipleEffectProvide,
|
|
5528
5618
|
outdatedEffectCodegen,
|
|
5529
5619
|
overriddenSchemaConstructor,
|
|
5530
|
-
unsupportedServiceAccessors
|
|
5620
|
+
unsupportedServiceAccessors,
|
|
5621
|
+
nonObjectEffectServiceType
|
|
5531
5622
|
];
|
|
5532
5623
|
|
|
5533
5624
|
// src/completions/effectDiagnosticsComment.ts
|