Skip to content

Fix formatting of conditional types - #21762

Merged
Mohamed Hegazy (mhegazy) merged 2 commits into
microsoft:masterfrom
lankaapura:Fix-21716
Feb 8, 2018
Merged

Fix formatting of conditional types#21762
Mohamed Hegazy (mhegazy) merged 2 commits into
microsoft:masterfrom
lankaapura:Fix-21716

Conversation

@lankaapura

Copy link
Copy Markdown
Contributor

Fixes #21716, pls review and let me know if there any changes required.

@mhegazy

Copy link
Copy Markdown
Contributor

thanks!

@mhegazy

Copy link
Copy Markdown
Contributor

Do you wana get the support for infer as well.. e.g.:

type C<T> = T extends Array<   infer     U  >? U : T;

@lankaapura

Copy link
Copy Markdown
Contributor Author

Mohamed Hegazy (@mhegazy) I've created a test and it seems this is not related to conditional type formatting. The reason is there are no infer formatting rules defined yet.

How do I proceed? Do you want me to update this PR or are you going to create a new issue?

Code     : "type C<  T  >   =   T   extends   Array   <   infer     U  >   ;"
Expected : "type C<T> = T extends Array<infer U>;"
Actual   : "type C<T> = T extends Array<infer     U>   ;"
Code     : "type C<  T  >   =   T   extends   Array   <   infer     U  >  ? U : T;"
Expected : "type C<T> = T extends Array<infer U> ? U : T;"
Actual   : "type C<T> = T extends Array<infer     U> ? U : T;"

Do you know where can I find more details about infer keyword and examples?

@mhegazy

Copy link
Copy Markdown
Contributor

it seems this is not related to conditional type formatting.

that is correct. the new keyword was added with conditional types, and is only allowed within the extends clause of a conditional type.

The reason is there are no infer formatting rules defined yet.

that is correct

How do I proceed? Do you want me to update this PR or are you going to create a new issue?

If you are interested you can just send a new PR for infer formatting.

Do you know where can I find more details about infer keyword and examples?

Here is the PR that added it: #21496

@microsoft Microsoft (microsoft) locked and limited conversation to collaborators Jul 3, 2018
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.

2 participants