Repository navigation
[BUGFIX] Keep generic classes generic through extend() - #21727
Open
NullVoxPopuli wants to merge 1 commit into
Open
NullVoxPopuli wants to merge 1 commit into
NullVoxPopuli wants to merge 1 commit into
Conversation
Contributor
📊 Size reportTarball size — dist/dev No changes
dist/prod No changes
smoke-tests/v2-app-template/dist No changes
smoke-tests/v2-app-hello-world-template/dist No changes
🤖 This report was automatically generated by wyvox/pkg-size |
NullVoxPopuli
marked this pull request as ready for review
October 15, 2026 15:27
`CoreObject.extend` rebuilt its return type from the instance type (`new (owner?) => Instance`), which fixed a generic class's type parameters. `Component.extend(Mixin)` then had a constructor that was not generic, so `class Foo extends Component.extend(Mixin)` could not take type arguments. In JS, TypeScript 7 reports TS2508 for `/** @extends {Component<Signature>} */` over that heritage, and the component loses its signature. Return `Statics` (the `this` type) instead, which keeps the original generic construct signatures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NullVoxPopuli
force-pushed
the
nvp/extend-keep-generic-constructor
branch
from
October 15, 2026 15:28
d810ae2 to
fe4c401
Compare
This branch has not been deployed
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.
Note
Investigated with Claude (via Claude Code); corrections welcome.
Component.extend(Mixin)now keepsComponent<S>generic, so a class that extends it can still take a signature. Today it can't. This matters most in JS, where TypeScript 7 reportsTS2508for this pattern and the component loses its signature.The change
Readonly<Statics> & EmberClassConstructor<Instance> & MergeArray<M>.EmberClassConstructor<Instance>isnew (owner?) => Instance, withInstancealready fixed toComponent<unknown>.Statics & MergeArray<M>.Staticsis thethistype, so its generic construct signatures carry through.Behavior change
Statics on the result are no longer
Readonly. No type test relied on that. AddingReadonly<Statics>back to the intersection would not restore it: an intersection property is readonly only if every member is.Why now
@extendsreplace the base type no matter whatextend()returned.@extendsis ignored when the heritage is a call expression (Base.extend()) microsoft/TypeScript#64058). With a constructor that isn't generic, that'sTS2508: No base constructor has the specified number of type arguments..gjswith ember-content-mapper (JSDoc @extends signature is lost for classic components with expression heritage (Component.extend(Mixin)) NullVoxPopuli/ember-content-mapper#12).Testing
type-tests/@ember/object-test/extend.tscoversclass StringBox extends Box.extend({})<string>(through aconst). It fails onmainwith the sameTS2508and passes with this change.type-check:internals,type-check:internals-stable-decorators,build:types,type-check:typesandtype-check:types-stable-decoratorsall pass (TS 5.9.3).type-check:typesandtype-check:types-stable-decoratorsalso pass on TS 5.2.2 and 7.0.2, the two ends of thetypes-rangeCI matrix.upstream-differencesfixture, the classicComponent.extend(Evented)component reports no errors on TS7.1.0-dev.20261015.1with these types. Today it reportsTS2508andTS2769.🤖 Generated with Claude Code