cypher-codegen: type-check generated query output under Effect v4#83
Merged
Conversation
Generated query modules failed to compile under Effect v4 in three ways: - Row decoding emitted an untyped Neo4jRecordToObject schema transform whose composition with the Row struct did not satisfy decodeTo's getter. Drop it: call record.toObject() in the Effect pipeline and validate each row directly with Schema.Array(Row), so the struct fully type-checks the decoded shape. - The TemporalString transform inferred Transformation<string, string>, which did not match its Schema.Unknown source. Emit explicit SchemaTransformation.transform<string, unknown> type parameters. - Single-file modules emitted untyped destructured params, an implicit any under strict mode. Thread resolved param types through generateModule and annotate them, matching the barrel output (shared via a queryParams helper). VitePlugin and Register now forward the analyzer's resolved params so module output is fully typed. Generated with AI Co-Authored-By: AI <ai@example.com>
The existing unit tests only assert on the emitted source string, so a regression where generated code fails to type-check could never surface as a failing test. Add a guard that runs the TypeScript checker over generateModule and generateBarrel output (using the repo's real compiler options) and asserts zero diagnostics — covering scalars, Neo4jInt, nullable, temporal, list, map, the Neo4jValue escape hatch, and typed params. Generated with AI Co-Authored-By: AI <ai@example.com>
jbmusso
force-pushed
the
effect-v4-codegen-fix
branch
from
June 4, 2026 21:01
dfbe850 to
8d03b0b
Compare
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Generated cypher-codegen query code did not type-check under Effect v4. This branch fixes the generator so its output compiles cleanly, and adds a compile guard so the class of regression can't silently return.
The previous unit tests only asserted on the emitted source string — they never compiled it — so "generated code fails
tsc" could never surface as a failing test. Adding a real compile guard immediately surfaced three distinct type errors in generated output, all fixed here.Fixes
Neo4jRecordToObjectschema transform (its composition with theRowstruct didn't satisfydecodeTo's getter under v4).record.toObject()is now called in the Effect pipeline and each row is validated directly withSchema.Array(Row), so the struct fully type-checks the decoded shape.TemporalStringtransform — inferredTransformation<string, string>, which didn't match itsSchema.Unknownsource. Now emits explicitSchemaTransformation.transform<string, unknown>type parameters. Theunknownis confined to the encoded boundary (the opaque neo4j temporal object); decoded values staystring.anyunderstrict). Resolved param types are now threaded throughgenerateModuleand annotated, matching the barrel output via a sharedqueryParamshelper.VitePluginandRegisterforward the analyzer's resolved params.Test guard
New
CypherCodegen.typecheck.node.unit.test.tsruns the TypeScript checker overgenerateModuleandgenerateBarreloutput (using the repo's real compiler options) and asserts zero diagnostics — covering scalars,Neo4jInt, nullable, temporal, list, map, theNeo4jValueescape hatch, and typed params. Addstypescriptas a package devDependency.Notes
unknown/anyin generated output is the encoded side ofTemporalString, the deliberateNeo4jValueescape hatch, and the no-schema untyped fallback (which has no param types to emit). Consumer-facing decoded/param types are fully typed.Verification
tsc -bclean, lint clean.Changeset
patchfor@evryg/effect-cypher-codegen.