Skip to content

Commit 0cd75d4

Browse files
committed
fix(types): use nonbroken implementation of Or
the old implementation of `Or` appears to have a strange bug relating to type evaluation when certain generic types are passed in. a github issue has been filed regarding this: microsoft/TypeScript#52068 in the meantime, a separate implementation that doesnt see this bug has replaced the original. this separate implementation, like the original, does not distribute the types
1 parent d62e82d commit 0cd75d4

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎packages/types/src/bool/or.d.ts‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
* checks if either `A` or `B` do not extend `false`
33
*/
44
export type Or<A extends boolean, B extends boolean> =
5-
[A, B] extends [false, false]
6-
? false
7-
: true
5+
/* there appears to be some strange behavior where this construct returns the wrong value
6+
* when used in a generic type, and either `A` or `B` use that generic type's type parameter in turn.
7+
* @see https://github.com/microsoft/TypeScript/issues/52068
8+
*/
9+
// [A, B] extends [false, false]
10+
// ? false
11+
// : true
12+
[A] extends [true] ? true
13+
: [B] extends [true] ? true
14+
: false

0 commit comments

Comments
 (0)