Repository navigation
fix: print the trait and variant builders by name in a consumer's declarations - #116
Merged
Merged
Conversation
jo16oh
added a commit
that referenced
this pull request
Nov 3, 2026
…claration (#118) Currently, `vp run ts-compatibility` searches the emitted `.d.ts` for `/*elided*/`. That text search catches one way a declaration loses a type. Compare the types themselves instead. - For each export of the book's code samples and the fixtures, assert that the source type and the type read back from its `.d.ts` are identical: ```ts import type * as S0 from "../fixture-builders.js"; import type * as D0 from "../dts/fixture-builders.js"; export type _0 = Expect<Equal<typeof S0.traitImpl, typeof D0.traitImpl>>; ``` - `Equal` distinguishes `any` from every other type. Against the dist before #116, `greetableBuilder`, whose declaration contains `/*elided*/ any`, fails on TypeScript 5.9, 6.0 and 7.0 - List the exports with the type checker from `typescript-5`. Compare a generic type as a function of its parameters: `<T0>() => S0.Result<T0>` - The repo's `scripts/` keep the `/*elided*/` search. Their classes extend `ErrorFactory(…)`, and their declarations print the aliases of `@praha/error-factory` expanded, which the comparison counts as a change - Export `ByTag`, `Frame` and `VariantSupplied` from `valof/internal/enum`. Currently, a consumer's declarations print them expanded, so `Shape[Tag]`, `Shape.Circle`, and `Shape.Circle` after its last step fail the comparison. The fixtures' declarations shrink from 36.8 kB to 33.8 kB. `index.d.ts` grows 0.02 kB - Run the TypeScript lines concurrently, each emitting to `dts/<alias>` and `round-trip/<alias>`. The reports print in the order of `aliases` `vp run ts-compatibility` takes 5.2 s instead of 4.4 s locally. Comparing the types costs 2.4 s per TypeScript line on 5.9 and 1.1 s on 7.0, mostly for the enum builders. With the lines run one after another, it takes 9.1 s.
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.
Currently, exporting a builder without
.build()breaks the declaration emit. TheCallBuildFirsterror that points to the missing.build()appears only where the builder is used:The compiler cannot print these builder types by name, so it writes the builder out again inside each step. A built companion is not affected.
TraitBuilderinto two interfaces,TraitStepsandTraitImplStep, so the declaration prints it by name afterimplEnumBuilder<…>from enum variant steps instead of the non-exportedAfter, and exportVariantStepsfromvalof/internal/enum/*elided*/index.d.ts+0.19 kB