Skip to content

Commit d23980a

Browse files
chore: update Effect v4 beta dependencies (#719)
1 parent 0af7c0f commit d23980a

7 files changed

Lines changed: 47 additions & 46 deletions

File tree

.changeset/fair-ducks-applaud.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect/language-service": patch
3+
---
4+
5+
Update the Effect v4 beta dependencies to `4.0.0-beta.43` for the language service and v4 harness packages.

packages/harness-effect-v4/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"dependencies": {
88
"@standard-schema/spec": "^1.1.0",
9-
"effect": "^4.0.0-beta.38"
9+
"effect": "^4.0.0-beta.43"
1010
},
1111
"devDependencies": {
1212
"@types/node": "^25.0.6"

packages/language-service/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
"perf": "tsx test/perf.ts"
4444
},
4545
"devDependencies": {
46-
"@effect/platform-node": "^4.0.0-beta.38",
46+
"@effect/platform-node": "^4.0.0-beta.43",
4747
"@types/pako": "^2.0.4",
4848
"@typescript-eslint/project-service": "^8.52.0",
49-
"effect": "^4.0.0-beta.38",
49+
"effect": "^4.0.0-beta.43",
5050
"pako": "^2.1.0",
5151
"ts-patch": "^3.3.0"
5252
}

packages/language-service/src/cli/overview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export function collectExportedItems(
136136
// Check if it's a Context.Tag (has _Identifier and _Service variance)
137137
const contextTagResult = yield* pipe(
138138
typeParser.contextTag(type, declaration),
139+
Nano.orElse(() => typeParser.serviceType(type, declaration)),
139140
Nano.option
140141
)
141142
if (Option.isSome(contextTagResult)) {

packages/language-service/src/core/TypeParser.ts

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,40 +1628,32 @@ export function make(
16281628
([Identifier, Service]) => ({ Identifier, Service })
16291629
)
16301630

1631-
const serviceVarianceStruct = (
1632-
type: ts.Type,
1633-
atLocation: ts.Node
1634-
) =>
1635-
Nano.map(
1636-
Nano.all(
1637-
varianceStructInvariantType(type, atLocation, "_Identifier"),
1638-
varianceStructInvariantType(type, atLocation, "_Service")
1639-
),
1640-
([Identifier, Service]) => ({ Identifier, Service })
1641-
)
1642-
16431631
const serviceType = Nano.cachedBy(
16441632
Nano.fn("TypeParser.serviceType")(function*(
16451633
type: ts.Type,
16461634
atLocation: ts.Node
16471635
) {
1636+
// v4 only
1637+
if (supportedEffect() !== "v4") return yield* typeParserIssue("v4 only")
16481638
// should be pipeable
16491639
yield* pipeableType(type, atLocation)
1650-
// get the properties to check (exclude non-property and optional properties)
1651-
const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter((_) =>
1652-
_.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration
1653-
)
1654-
// early exit
1655-
if (propertiesSymbols.length === 0) {
1656-
return yield* typeParserIssue("Type has no tag variance struct", type, atLocation)
1640+
// Effect v4 beta.43 switched ServiceMap keys from nested variance markers
1641+
const typeIdSymbol = typeChecker.getPropertyOfType(type, "~effect/ServiceMap/Service")
1642+
if (!typeIdSymbol) {
1643+
return yield* typeParserIssue("Type has no service key type id", type, atLocation)
16571644
}
1658-
// try to put typeid first (heuristic to optimize hot path)
1659-
propertiesSymbols.sort((a, b) => ts.symbolName(b).indexOf("TypeId") - ts.symbolName(a).indexOf("TypeId"))
1660-
// has a property symbol which is a service variance struct
1661-
return yield* Nano.firstSuccessOf(propertiesSymbols.map((propertySymbol) => {
1662-
const propertyType = typeChecker.getTypeOfSymbolAtLocation(propertySymbol, atLocation)
1663-
return serviceVarianceStruct(propertyType, atLocation)
1664-
}))
1645+
const identifierSymbol = typeChecker.getPropertyOfType(type, "Identifier")
1646+
if (!identifierSymbol) {
1647+
return yield* typeParserIssue("Type has no 'Identifier' property", type, atLocation)
1648+
}
1649+
const serviceSymbol = typeChecker.getPropertyOfType(type, "Service")
1650+
if (!serviceSymbol) {
1651+
return yield* typeParserIssue("Type has no 'Service' property", type, atLocation)
1652+
}
1653+
return ({
1654+
Identifier: typeChecker.getTypeOfSymbolAtLocation(identifierSymbol, atLocation),
1655+
Service: typeChecker.getTypeOfSymbolAtLocation(serviceSymbol, atLocation)
1656+
})
16651657
}),
16661658
"TypeParser.serviceType",
16671659
(type) => type
@@ -1672,6 +1664,8 @@ export function make(
16721664
type: ts.Type,
16731665
atLocation: ts.Node
16741666
) {
1667+
// v4 only
1668+
if (supportedEffect() !== "v3") return yield* typeParserIssue("v3 only")
16751669
// should be pipeable
16761670
yield* pipeableType(type, atLocation)
16771671
// get the properties to check (exclude non-property and optional properties)

packages/language-service/src/diagnostics/genericEffectServices.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const genericEffectServices = LSP.createDiagnostic({
4545
for (const [type, reportAt] of typesToCheck) {
4646
yield* pipe(
4747
typeParser.contextTag(type, node),
48+
Nano.orElse(() => typeParser.serviceType(type, node)),
4849
Nano.map(() => {
4950
report({
5051
location: reportAt,

pnpm-lock.yaml

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)