@effect/language-service 0.38.3 → 0.38.4
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 -1
- package/effect-lsp-patch-utils.js +16 -7
- package/effect-lsp-patch-utils.js.map +1 -1
- package/index.js +16 -7
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/transform.js +16 -7
- package/transform.js.map +1 -1
package/README.md
CHANGED
|
@@ -79,7 +79,7 @@ And you're done! You'll now be able to use a set of refactors and diagnostics th
|
|
|
79
79
|
- Transform an async function definition, into an Effect by using Effect.fn.
|
|
80
80
|
- Transform an async function definition, into an Effect by using Effect.fn, and generating a tagged error for each promise call.
|
|
81
81
|
- Transform a function returning an Effect.gen into a Effect.fn
|
|
82
|
-
- Implement Service accessors in an `Effect.Service` or `
|
|
82
|
+
- Implement Service accessors in an `Effect.Service`, `Context.Tag` or `Effect.Tag` declaration
|
|
83
83
|
- Function calls to pipe: Transform a set of function calls to a pipe() call.
|
|
84
84
|
- Pipe to datafirst: Transform a pipe() call into a series of datafirst function calls (where available).
|
|
85
85
|
- Toggle return type signature: With a single refactor, adds or removes type annotations from the definition.
|
|
@@ -4525,6 +4525,7 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
|
|
|
4525
4525
|
const ts = yield* service(TypeScriptApi);
|
|
4526
4526
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
4527
4527
|
const typeParser = yield* service(TypeParser);
|
|
4528
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
4528
4529
|
if (!ts.isClassDeclaration(node)) return yield* fail("not a class declaration");
|
|
4529
4530
|
const { Service, accessors: accessors2, className } = yield* pipe(
|
|
4530
4531
|
typeParser.extendsEffectService(node),
|
|
@@ -4533,12 +4534,18 @@ var parse2 = fn("writeTagClassAccessors.parse")(function* (node) {
|
|
|
4533
4534
|
);
|
|
4534
4535
|
if (accessors2 !== true) return yield* fail("accessors are not enabled in the Effect.Service call");
|
|
4535
4536
|
const involvedMembers = [];
|
|
4536
|
-
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
|
|
4537
|
+
const nonPrimitiveServices = typeCheckerUtils.unrollUnionMembers(Service).filter(
|
|
4538
|
+
(_) => !(_.flags & ts.TypeFlags.Number || _.flags & ts.TypeFlags.String || _.flags & ts.TypeFlags.Boolean || _.flags & ts.TypeFlags.Literal)
|
|
4539
|
+
);
|
|
4540
|
+
if (nonPrimitiveServices.length === 0) return yield* fail("Service type is a primitive type");
|
|
4541
|
+
for (const serviceShape of nonPrimitiveServices) {
|
|
4542
|
+
for (const property of typeChecker.getPropertiesOfType(serviceShape)) {
|
|
4543
|
+
const propertyType = typeChecker.getTypeOfSymbolAtLocation(property, node);
|
|
4544
|
+
const callSignatures = typeChecker.getSignaturesOfType(propertyType, ts.SignatureKind.Call);
|
|
4545
|
+
if (callSignatures.length > 0) {
|
|
4546
|
+
const withTypeParameters = callSignatures.filter((_) => _.typeParameters && _.typeParameters.length > 0);
|
|
4547
|
+
if (callSignatures.length > 1 || withTypeParameters.length > 0) involvedMembers.push({ property, propertyType });
|
|
4548
|
+
}
|
|
4542
4549
|
}
|
|
4543
4550
|
}
|
|
4544
4551
|
const hash2 = involvedMembers.map(({ property, propertyType }) => {
|
|
@@ -4584,6 +4591,7 @@ var accessors = createCodegen({
|
|
|
4584
4591
|
const tsUtils = yield* service(TypeScriptUtils);
|
|
4585
4592
|
const typeChecker = yield* service(TypeCheckerApi);
|
|
4586
4593
|
const typeParser = yield* service(TypeParser);
|
|
4594
|
+
const typeCheckerUtils = yield* service(TypeCheckerUtils);
|
|
4587
4595
|
const nodeAndCommentRange = tsUtils.findNodeWithLeadingCommentAtPosition(sourceFile, textRange.pos);
|
|
4588
4596
|
if (!nodeAndCommentRange) return yield* fail(new CodegenNotApplicableError("no node and comment range"));
|
|
4589
4597
|
return yield* pipe(
|
|
@@ -4597,7 +4605,8 @@ var accessors = createCodegen({
|
|
|
4597
4605
|
provideService(TypeScriptApi, ts),
|
|
4598
4606
|
provideService(TypeScriptUtils, tsUtils),
|
|
4599
4607
|
provideService(TypeCheckerApi, typeChecker),
|
|
4600
|
-
provideService(TypeParser, typeParser)
|
|
4608
|
+
provideService(TypeParser, typeParser),
|
|
4609
|
+
provideService(TypeCheckerUtils, typeCheckerUtils)
|
|
4601
4610
|
)
|
|
4602
4611
|
})
|
|
4603
4612
|
),
|