-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support re-aliasing of type alias instantiations #42284
Conversation
@typescript-bot test this |
Heya @ahejlsberg, I've started to run the abridged perf test suite on this PR at 8ac7030. You can monitor the build here. Update: The results are in! |
Heya @ahejlsberg, I've started to run the parallelized community code test suite on this PR at 8ac7030. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the extended test suite on this PR at 8ac7030. You can monitor the build here. |
Heya @ahejlsberg, I've started to run the parallelized Definitely Typed test suite on this PR at 8ac7030. You can monitor the build here. |
@ahejlsberg Here they are:Comparison Report - master..42284
System
Hosts
Scenarios
|
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
Tests all look good, only changes are improved diagnostics. Performance is unaffected. |
@typescript-bot pack this |
Heya @DanielRosenwasser, I've started to run the tarball bundle task on this PR at 8ac7030. You can monitor the build here. |
Hey @DanielRosenwasser, I've packed this into an installable tgz. You can install it for testing by referencing it in your
and then running There is also a playground for this build and an npm module you can use via |
!!! error TS2322: Type 'keyof T' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. | ||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. | ||
!!! error TS2322: Type 'string' is not assignable to type 'T[keyof T] extends Function ? never : keyof T'. | ||
!!! error TS2322: Type 'keyof T' is not assignable to type 'never'. | ||
!!! error TS2322: Type 'string | number | symbol' is not assignable to type 'never'. | ||
!!! error TS2322: Type 'string' is not assignable to type 'never'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why's this happening? What was avoiding the elaboration before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like we can't avoid re-elaboration based on type IDs
@ahejlsberg This is even better than the previous attempt 🎉 As before, there are no inlining/size regressions - I reviewed every changed line and this PR is a pure win. This PR improves upon 2c2d06d by also handling aliases to // Previous: 2c2d06
myRecordProp: Record<string, any>;
myObjectProp: Pick<{
lotsOfProps,
}, "red" | "green" | "blue
>; ...is replaced by... // Master: Using PR#42284
myRecordProp: MyRecordType;
myObjectProp: MyColorsOnly<{
lotsOfProps,
}
>; On the large package I referred to in previous reports, this PR results in a further 10KB decrease vs the previous attempt, i.e the
|
* New aliases for type alias instantiations * New aliases for conditional, mapped, and anonymous object type instantiations * Accept new baselines * Fix issues with re-aliasing * Accept new baselines
This PR continues the work in #42149 by supporting re-aliasing of type alias instantiations. For example:
Previously, instantiations of aliased anonymous object, mapped, or conditional types with a new type alias would continue to display the original type alias in diagnostics, quick info, and declaration files. Now, re-aliasing of such types consistently adopts and displays the new type alias.
In addition, instantiations of distributive types (such as homomorphic mapped types and distributive conditional types) now properly preserve the original type alias when the instantiation results in a union type: