Using <X>() => X extends V ? 1 : 2
ignores readonly in object properties of V when called via a type alias
#55618
Labels
Duplicate
An existing issue was already created
🔎 Search Terms
readonly property ignored in type alias
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?ts=5.2.2#code/PQKgUABBAcCc0QLQQJIDsDGAbArgEwFMBnSJRci0gIwE8I0cssIAKAAQGsa0CAzHDgEoIAYgIBDInRHiATrPE0wpEaogBFHMQAuASwD2aZVBQBbAA5YCpgmm0RtACwIQAUuIBu4gMoZZu83sAAwBBeUUAOl1MXEIiIIh+TD1DCGiHZwcacxcpIm1rCIgQrJyHcQ5iDJdtAHd9CDkAcxwbOyIigBVM-Rxtcz6IIkderDwIKhdxCf19K3E0CCDtWS0E-Vkl3nEsIgIgiOMIADENiAIAD3ELKwAuI6DH7RIobWyXXSIABV0mOQBZWwQAC8qBi+GIAB4ANoAcgA0nIiLCADQQWEAUSIujwn10qPRAHVrjgcATYd4FtoFuJYQBdNGwgAiBlhAD4IMBgOcLjkMAVxtoGpMtjs9kFSI8JaQOQA1XQEWoQVIAcV02gAEjgqLcII5tP0iLcuc8MI4IgArDobJrAODQMAgYDKUAQAD6Hs9Xs9EAAmr1NgBhfSECAagiyFze6MeiBOl3c7y1dVmiYEOoEIFefxUogTOiSbFNNDRJrVBw6AjjbO6Kl6iMEQ5vMrobAQoiQzo8gpoPB5yPiPCGLAFtA0aEMiAAVQ5wNIrdixAATJ20TOoJzufVZBw87VnIscNi0GWF+2AMxos9xc9UK-guIAFlIG9fb-fXKGI0Y4zFDW3HAQMmThgm2cRLo0vagYuRBLneL7vohr6flAVCDLoxYbFUA5DmgI5pIs+hUBaBD8hA5iyPoOSyHoxDKM2LjXsQACMnbdrYfYQDhw6juOk7rnOUBTuxvZ5p00IMKYkyyHSEAAPwOKsLi6tsuwuJ+Q5VGg+j2EQcweDUjifBAZo7FgCxNAQCYQN0xAuDWuZfqMv5MEM+mGS4plMLYln3GADEQMGFhyBGkKyrOECQgAGmyLDCMCHJ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vc6efznn100W40pHirlxIKRAAAPtbdZryLkQo+d42F1sCkItBVErJKLREMCYJOHAvY+DRCrJit5yL9EkKJYQXgpK8CTnxVgclvC6QuhAO6R+Ppjg4Bos4TY3gCjmDzFyn08ZQAyggN4RwIUIDtV5W5XAKQ0BGj1AaYVxpgCmnNFaCINo7TwGAAsIgtQIySvlIqRVSDDCqv1IaTV2rLTWlkLae0wA9JKoMCqyV-wsKBRld5eBtr1VGhNEQM0Tq9UusdM6IAA
💻 Code
🙁 Actual behavior
When the type alias
Comparer<V>
is called from the type aliasIncludes2
, it ignoresreadonly
attributes of object properties in the type comparison. BothT1
andT2
result in the typetrue
.🙂 Expected behavior
When the type alias
Comparer<V>
is called from the type aliasIncludes2
, it should not ignorereadonly
attributes of object type properties in the type comparison. BothT1
andT2
should result in the typefalse
.That is,
Includes2
should behave exactly asIncludes3
, which is identical toIncludes2
except that it has inlined the call toComparer<V>
and does not ignorereadonly
attributes of object type properties. (Here,T1
andT2
both result in the typefalse
.)Additional information about the issue
For reproducing the problem in the playground, please activate
@Type Challenges/plugin
.For an explanation of the sample code see the solution for the
Includes
type challenge here:898 - Includes - Non-recursive solution using array union with explanations.
The text was updated successfully, but these errors were encountered: