Repository navigation
IDE DX Improvements - #15
Merged
Merged
Conversation
…operty removal - Added optional third type argument to `BuilderWith` and `ClassBuilderWith` for property name autocompletion in instance methods. - Improved compile error messages for `build()` and related methods to clearly indicate missing required properties. - Introduced `removeRequiredProperty(key)` method to auto builders and deprecated builders, allowing removal of required properties while returning a new builder. - Deprecated several helper types that are now redundant due to the new builder functionalities, with clear migration paths provided. - Updated setter methods to link directly to their corresponding properties, enhancing navigation and documentation visibility in IDEs.
committedpazz
approved these changes
Oct 6, 2026
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
This branch makes the auto builders nicer to work with in the editor and deprecates the helper types they made redundant. It holds five changesets, all
minor.Nothing that compiled before stops compiling, except one reserved-name edge case (see Compatibility). The only runtime change is the new
removeRequiredPropertymethod.What changes
1. Ctrl+Click on a setter opens the property it sets
Go to Definition on
builder.city(...)now openscityin your own type or class. Hovering the setter shows the property's doc comment, and renaming the property also renames the setter calls.How: the setters are now generated by two mapped types instead of one.
…Prop. These stay unlinked.Setter names, parameter types and union-target behaviour are unchanged. Compiling the test suite now takes roughly half as many type instantiations.
2. Property-name autocomplete in
BuilderWith/ClassBuilderWithAn optional third type argument names the builder class. Editors look up the property names there, so the keys autocomplete inside the quotes:
It defaults to the first argument, so existing two-argument uses are unaffected.
3. A too-early
build()names what is missingThe compile-time-checked build variants now check the builder they are called on themselves. When the check fails, the error ends in
MissingRequiredProperties<…>:Previously the error was a four-line chain that printed the builder's full brand type up to three times before reaching the missing names. This applies to the auto builders and to the deprecated builders.
MissingRequiredPropertiesis exported.4.
removeRequiredProperty(key)This is the counterpart of
removeOptionalProperty. The main use is building an invalid object for a negative test:RemovedRequiredProperties<K>marker, which keepsbuild()and the other checked variants unavailable, even if the property is set again later.buildUnsafe(),buildPartial()orbuildWithoutCompileTimeValidation(). The last one still runs the runtime checks.5. Deprecate helper types superseded by the auto builders
All of these are still exported and still work. Each
@deprecatedtag names its replacement:BuilderStep/ClassBuilderStepBuilderWith<this, "key", YourBuilder>/ClassBuilderWithBuilderPreset/ClassBuilderPresetBuilderWith<YourBuilder, "key">/ClassBuilderWithBuilderComposer/ClassBuilderComposerBuilderComposerFromFactory/ClassBuilderComposerFromFactoryBuildGate/ClassBuildGateBuilderWith<YourBuilder>/ClassBuilderWith<YourBuilder>RequiredFieldsTemplateRequiredFieldsRecord<T>, orReadonlyArray<Path<T>>for nested pathsGenerated setters now return a new, non-deprecated
InternalBuilderStep/InternalClassBuilderStep. Both are exported, so consumers' declaration emit can name them. It is the same type under a new name, so hovers and the build error never name a deprecated type. This follows the pattern 1.6.0 used forCeriosBrand→InternalBuilderBrand.I checked two cases where a replacement might not fit:
BuilderWith<this, K, UserBuilder>works with a genericK.BuildGate: generic code constrained with it never could callbuild(), so deprecating it loses nothing.Docs
BuilderInitexample.static requiredTemplate/static requiredDataPropertiesdeclared on your own subclass can't be flagged by TypeScript or lint, with a grep to find them.ClassConstructorentry corrected.BuilderInitshown in forms that actually compile. The previous one-argumentBuilderInit<T>did not compile.BuilderWithinstead.BuilderWithno longer explains itself throughsetNestedProperty.Compatibility
removeRequiredPropertyjoins the reserved builder names. A property literally namedremoveRequiredPropertyis now set withremoveRequiredPropertyProp.InternalBuilderStep<…>instead ofBuilderStep<…>. The type is identical.no-deprecatedrule get a warning wherever they name one of the nine deprecated types. Inferred types, hovers and the recommended helpers never warn.Verification
npm run compile,npm test(645 passing),npm run lint,npm run format:check,npm run buildandnpm run check-exportsall pass.dist/index.d.mtshas 17@deprecatedtags (was 8) and exportsInternalBuilderStep/InternalClassBuilderStep.tests/, sincetests/**turnsno-deprecatedoff):build()namesInternalBuilderStep.removeRequiredPropertyon all four builders;BuilderWith/ClassBuilderWiththird argument;InternalBuilderStep.Left for the next major
CeriosBuilder/CeriosClassBuilder.requiredTemplatefromAutoBuilderConstructor.CeriosAutoBuilder<T>()returns one shared runtime class for everyT, so assigning the static there leaks into every auto builder. The class builder already droppedrequiredDataPropertiesfor the same reason.Housekeeping:
.gitignorenow ignores*.tgzpackage archives.🤖 Generated with Claude Code