Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/update-effect-beta-19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@effect/language-service": patch
---

Update effect dependency to v4.0.0-beta.19 and fix compatibility issues:

- Fix `layerMagic` refactor producing `any` types in Layer channels by replacing `Array.partition` (which now uses the v4 `Filter.Filter` API) with a native loop for boolean partition logic
- Add v4 Layer type detection shortcut using `"~effect/Layer"` TypeId property, matching the pattern already used for Effect type detection
- Mark `Effect.filterMap` as unchanged in the outdated API migration database since it was re-added in v4
2 changes: 1 addition & 1 deletion packages/harness-effect-v4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"check": "tsc -b tsconfig.json"
},
"dependencies": {
"effect": "^4.0.0-beta.14",
"effect": "^4.0.0-beta.19",
"@standard-schema/spec": "^1.1.0"
}
}
4 changes: 2 additions & 2 deletions packages/language-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
"devDependencies": {
"pako": "^2.1.0",
"@typescript-eslint/project-service": "^8.52.0",
"@effect/platform-node": "^4.0.0-beta.14",
"@effect/platform-node": "^4.0.0-beta.19",
"@types/pako": "^2.0.4",
"effect": "^4.0.0-beta.14",
"effect": "^4.0.0-beta.19",
"ts-patch": "^3.3.0"
}
}
10 changes: 10 additions & 0 deletions packages/language-service/src/core/TypeParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,16 @@ export function make(
// should be pipeable
yield* pipeableType(type, atLocation)

if (supportedEffect() === "v4") {
// Effect v4 TypeId shortcut
const typeIdSymbol = typeChecker.getPropertyOfType(type, "~effect/Layer")
if (typeIdSymbol) {
const typeIdType = typeChecker.getTypeOfSymbolAtLocation(typeIdSymbol, atLocation)
return yield* layerVarianceStruct(typeIdType, atLocation)
}
return yield* typeParserIssue("Type is not a layer", type, atLocation)
}

// get the properties to check (exclude non-property and optional properties)
const propertiesSymbols = typeChecker.getPropertiesOfType(type).filter((_) =>
_.flags & ts.SymbolFlags.Property && !(_.flags & ts.SymbolFlags.Optional) && _.valueDeclaration
Expand Down
4 changes: 1 addition & 3 deletions packages/language-service/src/diagnostics/outdatedApi.db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ export const effectModuleMigrationDb: ModuleMigrationDb = {
"failSync": asUnchanged,
"fiberId": asUnchanged,
"filter": asUnchanged,
"filterMap": asRemoved(
"Use Effect.filter or Effect.map with Option instead."
),
"filterMap": asUnchanged,
"filterOrElse": asUnchanged,
"filterOrFail": asUnchanged,
"flatMap": asUnchanged,
Expand Down
16 changes: 11 additions & 5 deletions packages/language-service/src/refactors/layerMagic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,19 @@ export const layerMagic = LSP.createRefactor({
Nano.option
)

const [existingBefore, newlyIntroduced] = pipe(
const sorted = pipe(
Array.fromIterable(layerOutputTypes),
Array.sort(typeCheckerUtils.deterministicTypeOrder),
Array.partition((_) =>
Option.isNone(previouslyProvided) || typeChecker.isTypeAssignableTo(_, previouslyProvided.value)
)
Array.sort(typeCheckerUtils.deterministicTypeOrder)
)
const existingBefore: Array<ts.Type> = []
const newlyIntroduced: Array<ts.Type> = []
for (const t of sorted) {
if (Option.isNone(previouslyProvided) || typeChecker.isTypeAssignableTo(t, previouslyProvided.value)) {
newlyIntroduced.push(t)
} else {
existingBefore.push(t)
}
}

const typeReferences = pipe(
newlyIntroduced,
Expand Down
34 changes: 17 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading