GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — Support re-aliasing of type alias instantiations by ahejlsberg · Pull Request #42284 · microsoft/TypeScript Conversation
Member
This PR continues the work in #42149 by supporting re-aliasing of type alias instantiations. For example: type Thing<T> = { value: T }; type ArrayThing<U> = Thing<U[]>; type StringArrayThing = ArrayThing<string>; declare let t1: Thing<string[]>; // Thing<string[]> declare let t2: ArrayThing<string>; // ArrayThing<string> (previously Thing<string[]>) declare let t3: StringArrayThing; // StringArrayThing (previously Thing<string[]>) interface Item<T> { value: T } type ArrayItem<U> = Item<U[]>; type NumberArrayItem = ArrayItem<number>; declare let t4: Item<number[]>; // Item<number[]> declare let t5: ArrayItem<number>; // ArrayItem<number> declare let t6: NumberArrayItem; // NumberArrayItem (previously ArrayItem<number>) function foo<T, K extends keyof T>(obj: T, key: K) { let x: Omit<T, K>; // Omit<T, K> (previously Pick<T, Exclude<keyof T, K>>) } 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: type A = { a: string }; type B = { b: string }; declare let p: Partial<A | B>; // Partial<A | B> (previously Partial<A> | Partial<B>)
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was an error while loading. Please reload this page.
|
Heya Anders Hejlsberg (@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! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized community code test suite on this PR at 8ac7030. You can monitor the build here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 8ac7030. You can monitor the build here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 8ac7030. You can monitor the build here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Rob Palmer (@robpalme) This is the continuation PR I mentioned in #42149. Give it a try and let me know how it goes. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Anders Hejlsberg (@ahejlsberg) Here they are:Comparison Report - master..42284
System
Hosts
Scenarios
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The user suite test run you requested has finished and failed. I've opened a PR with the baseline diff from master. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Tests all look good, only changes are improved diagnostics. Performance is unaffected. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
TypeScript Bot (@typescript-bot) pack this |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Heya Daniel Rosenwasser (@DanielRosenwasser), I've started to run the tarball bundle task on this PR at 8ac7030. You can monitor the build here. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Hey Daniel Rosenwasser (@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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| !!! 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.
The reason will be displayed to describe this comment to others. Learn more.
Why's this happening? What was avoiding the elaboration before?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem 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
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Anders Hejlsberg (@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
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
* 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
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.