Skip to content

Unconstrained type variable not assignable to 'object' - #23806

Merged
Anders Hejlsberg (ahejlsberg) merged 5 commits into
masterfrom
objectAndUnconstrainedTypeParameter
May 1, 2018
Merged

Anders Hejlsberg (ahejlsberg) merged 5 commits into
masterfrom
objectAndUnconstrainedTypeParameter

Conversation

@ahejlsberg

Copy link
Copy Markdown
Member

Fixes #23800.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, although the tests don't make all the assertions that the comments in the tests do.

type A<T, V> = { [P in keyof T]: T[P] extends V ? 1 : 0; };
type B<T, V> = { [P in keyof T]: T[P] extends V | object ? 1 : 0; };

type a = A<{ a: 0 | 1 }, 0>; // { a: 0; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the baselines don't actually show that type a = { a: 0 } (or that type b = { a: 0 }.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants