-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Structural never
type breaks conditional types
#57210
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
Comments
Related to #53027, which observes that impossible intersections behave differently from Very similar in nature (possibly a re-appearance of the same bug?) to #42859 and looks like it should have been fixed by #42917. Also, even though a the literal type R0 = ReturnType<{x:0} & {x:1} & {x:never} & (()=>"X")> // type R0 = "X"
// ^?
type R1 = ReturnType<{x:0} & {x:1} & {x:any} & (()=>"X")> // type R1 = unknown
// ^? |
This part, at least, seems to have been fully intentional per the linked #36696:
|
Yeah, definitely intentional, but also strange. The rationale given was that if a property had disjoint types, the object type can't exist. But the |
It's not possible to statically detect all "structural |
@RyanCavanaugh This issue is about intersections that are already statically reduced to |
I'm not saying we should detect all structural The case
π Previously |
This issue has been marked as "Not a Defect" and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
@RyanCavanaugh please reopen. I believe you missed the thrust of this issue. |
π Search Terms
never, intersection, contradiction
π Version & Regression Information
never
β― Playground Link
https://www.typescriptlang.org/dev/bug-workbench/?#code/PTAEBUAsFMGdtANwIYCcCWyAu6D2A7WUA0faRaVUNBAI1y0lFWgAddUtoATUWgT1Dp8XADaj08QgmREABmQqo5AOgCwAKBARI2AORFkoVqly1R0ALZ9oAY2QBXeKEbRBtaLoqhu6AGZ+lNAiooLC1KCwDrRYFqAA7sj8mlj8rAgAcriWwsiiGeSUoAC8pIWomtqgoAB6APwpaQgAylioDrZYDqh5BUoloADeAB4AXACMAL6gAGRDYwBMk5Vg1fWaK6AA6gjx6OI2oNDDrKIcwgDmLpCSCeiM13QO+zj4oABK0F2o+OBNoBdgpR0LYXE1Nql0h8vt1fk0ADzgI7DLj4bhEAAUKmxaAusFG1Hw-AAlCUAHyE-gU0pI46o9GgLE41B4gnIImk4oU4SBKjvUB1D6gNlEgDcGy0YE+3zhUNsBFgbWQwiIrgBQIwoNguFIBAAtPZxMhzAhIXAAehvEYnNA-A5REdUKYqJY4LBkIDNgABLCwPXHdKdf1OjiNKHvAAMA2lsL+6XhIwmkwp2koztAeqQlEEMFErDtogAhBLtApynIhKqWNgeJFA5hxO5BGr5Wj7nh8HkwXKFW0OlgITBQK3fDgCF3brBIBwsAb0KhbM8uLx2bwWwRRx2u+Q8g4a6qdWWlBWVVxkLxcH4jvcYFQ1X2EBxQH48s5aD18LZIOoNGaPuNoxhH442geFFEoFMwHAipJWqWoGg0TZaAcLA7gedkhEsdhYFgdATSEERKHgToOwAGk2cYVEebsEFbRUemEVDuFwc18AYUAAGsQQ4gjqEMSJkECC491QbhNgWKj1zbMdOwdW42NQqcZznBcl1rLAdT0aC9E2ABmSShxHdtxwdHdRD3LgD2oh8+A-L9iHwUIjgoN5GFwBwLiYVwWAMXVmGgWQSA04wWF5a9vNs9kv0HBAWBlGjKwI3kWBXeQHHwDi2PifA5FIyJoCsS4nI8ewbSELBfIwhxWHSKh6HSi9XKHP9WDQZBXS4GDtD-d4FgGdLMtwbLRWRQNlzKJQwwQXrAJlECEzGKZZnmUYljJTY1gQzZCjefwIji2EEtuAAqej+26PJQmOnw7FEGhuDy+5EvQC42JSvhm3+Hkgk-aAIX+d5dP6jKsvwEaAzscaACIAA0oamj4gdKGNgIRRMlrmRMlmWjEmRUXF8UpABtABdTkKVhqHiXW2DNqAA
π» Code
π Actual behavior
When intersecting two object types with a conflicting value, the user-observable hinted type is
never
, but the type interacts with generic templates in a nonsensical way.π Expected behavior
I expect either (or both):
never
type for constrained generics and conditional types. In particular:never
never
" type.never
s merit different compiler behavior (e.g. when trying to access a property on a conflicted type) so showing it as e.g.never<"conflicted .x">
would go a long way to making the behavior less frustratingly opaque.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: