You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inconsistent extends check when comparing a directly written generic (Template<'a'>) to a type-aliased version of the same generic (TA = Template<'a'>)
#61548
Open
Gguigre opened this issue
Apr 7, 2025
· 3 comments
typeAOrB='a'|'b'typeAOrBProps={type: 'a'spec: 'spec a'}|{type: "b"spec: 'spec b'}typeTemplate<TextendsAOrB='a'|'b'>={// this causes the bugtype: Tspec: Extract<AOrBProps,{type: T}>["spec"]}typeTA=Template<'a'>typeRes1=Template<'a'>extendsTemplate ? true : false// should be false and is false : β // ^?typeRes2=TAextendsTemplate ? true : false// should be false and is true : β// ^?// same bug if I use typeof -------------------constp={type: 'a',spec: 'spec a'}asconsttypeRes3=typeofpextendsTemplate ? true : false// should be false and is true : β// ^?
π Actual behavior
Types declared as equals (TA and Template<'a'>) does not behave the same when compared to a third type (Template)
π Expected behavior
As TA = Template<'a'> I would expect Res1 and Res2 to be the same (false)
Yes, seems likea duplicate but the other issue was automatically closed because there was no update. Should we investigate what broke the type aliasing ?
the other issue was automatically closed because there was no update
It was closed because it was marked as a "Design Limitation", which means there's nothing they can do about it in the foreseeable future.
Should we investigate what broke the type aliasing ?
π€·ββ I'm not a team member. But if you have a fix that doesn't have horrendous performance costs and doesn't break anything else I'm sure the team would be happy to accept it.
π Search Terms
"Alias equality", "extends broken by alias template", "generic type extension", "extends transitivity typescript"
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBAgg8gJwEJQLxQOQEMNQD6YBGGAUCaJLIkgAoID2YAzmlAN4lRQUQBcmOTlCaQAxvwwiIoqIIC++dkJ78ARIVVCp4zNqjEScsjygAVCAFswAGyzAIAHlNQIAD3sA7ACYt4yVti4BBjEAHys7FAA9FHcABYAliyiWACuTBAswHHQhKkA5srgfGZaYvwAou4IWKLADn60DMwANOwqZnKhANqq2qoAuobGxWYwrOZWtvYOgaEjlABKmQCME5Y2do5zLu4Q3iyTm-ZQAPzcCKnQ-ABmWNYZ0bFMcfSp1l760HcP0FjeUCSUB+j34gFByEgxLhQAB6pwW0GWTAATBNxm5PD4zBtptBzsBLtdgfdHlCXm8Pl9ib9ZACgQSrlB+IAZckhsVh8LIZKwFlyBUBNygAEkoOloDx6IKALQy2Vy+VykiiegeJjAKBgVgcLgdQItMrSCR6eSyZIqtUIqBIgDMrAlgs1GP2WKOuLOF0ZtxJ0DJr3en0I329tM+9MJTKgrKhXDhQA
π» Code
π Actual behavior
Types declared as equals (
TA
andTemplate<'a'>
) does not behave the same when compared to a third type (Template
)π Expected behavior
As
TA
=Template<'a'>
I would expect Res1 and Res2 to be the same (false
)Additional information about the issue
Working on this issue with @GuillaumeEgret
The text was updated successfully, but these errors were encountered: