-
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
Better display representation for intersection types #7705
Comments
👍 |
so just to be clear is the request 1. to remove the empty object type if exists, or 2. to collapse all types. i.e.: type T = { } & { a: number } & { b: string };
var x: T; // What is x?
// 1. { a: number } & { b: string }
// 2. { a: number, b: string } |
The second actually. |
ok one more clarification, i assume this only applies to anonymous types. so 2.a would be the desired behavior. class C { c: boolean; }
type T = C & { a: number } & { b: string };
var x: T; // What is x?
// 2.a C & { a: number; b: string }
// 2.b { a: number, b: string; c: boolean } |
I suppose it's better to limit this to anonymous types, or else it could rapidly go out of control with "big" named types, and you'll lose some type information. |
related #6070 |
Accepting PRs, with a big caveat. This is actually quite a bit trickier than it appears because of how the compiler handles anonymous self-referential types. A PR here should be accompanied by a large test suite of recursively self-referential types to ensure there aren't any lingering runaway recursion bugs. See also comments in #8228. |
I'm not sure if this has been discussed before, but join types are mostly unreadable. I think the type should be prettified somehow before being displayed to the user.
TypeScript Version:
1.8
Code
Expected behavior:
Actual behavior:
The text was updated successfully, but these errors were encountered: