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
type_Exclude<T,U>=TextendsU ? never : T;typeMyType1=1|2|3|4typeMyType2=3|4|5|6typeResult1=_Exclude<MyType1,MyType2>// 1 | 2typeResult2=MyType1extendsMyType2 ? never : MyType1// 1 | 2 | 3 | 4typeResult3=[MyType1]extendsMyType2 ? never : MyType1// 1 | 2 | 3 | 4// Maybe an improvement for non-generic cases?typeResult4=[KinMyType1]extendsMyType2 ? never : K// ERROR
🙁 Actual behavior
Using "Distributive Conditional Types" in a generic type behaves differently compared to using concrete types. (Not Referential transparent)
🙂 Expected behavior
"Distributive Conditional Types" always works the same, no matter if it is being used in generic types or not.
Additional information about the issue
If "Distributive Conditional Types" should behave differently, I believe it worth providing a way for non-generic types to be able to distribute over the union type in conditional types, same as how it works in generics. Maybe having a syntax like:
typeMyType1=1|2|3|4typeMyType2=3|4|5|6typeResult4=[KinMyType1]extendsMyType2 ? never : K
The text was updated successfully, but these errors were encountered:
This isn’t a bug, it’s the intended behavior of distributive conditional types. The suggestion at the end is a duplicate of or strongly related to #30572.
🔎 Search Terms
site:github.com/microsoft/TypeScript Exclude
site:github.com/microsoft/TypeScript Exclude behaves differently
TypeScript Exclude inconsistent
TypeScript Exclude different
TypeScript Exclude behaves differently expanded
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play/?#code/C4TwDgpgBAsiAq4IEYoF4qoD5QExRwGYCoAWAKFElgSXw2J1JIFYSA2crq6AfQFEAHgGMANgFcAJhAA88ADRQAqgD50UeFAiDgEAHaSAzsqgB+KHogA3CACcoALg0BubkigAlCIfGjgqDAERCWkZOERIZEVwujUoKAB6BMwSXEp3Lx8-ehoIlC0dfSNcujMLaztHEsj4+KSUnHwiEgoeT29fYGIMAG0YyIBdAt0DY36IfHNLG3sncdRa+uw8EkYyLnqYAEMQACNoLb0oAEsAWzBbAHsbU-1gKAAzS-s9S70AWgBzfTtj4ShhFtDN5TOlqJlOsxegBpE5HeZDbQjYrjSblGZVWGLZL8DweADyHi4QA
💻 Code
🙁 Actual behavior
Using "Distributive Conditional Types" in a generic type behaves differently compared to using concrete types. (Not Referential transparent)
🙂 Expected behavior
"Distributive Conditional Types" always works the same, no matter if it is being used in generic types or not.
Additional information about the issue
If "Distributive Conditional Types" should behave differently, I believe it worth providing a way for non-generic types to be able to distribute over the union type in conditional types, same as how it works in generics. Maybe having a syntax like:
The text was updated successfully, but these errors were encountered: