Skip to content

Commit

Permalink
three: Fix ConstructorUnion's distributivity (#62011)
Browse files Browse the repository at this point in the history
Typescript 4.9 [optimises substitution
types](https://github.com/microsoft/TypeScript/pull/50397a), but this
exposes that ConstructorUnion isn't correctly distributive.

I used the [fix suggested by Anders
Hejslberg](microsoft/TypeScript#50397 (comment))
on the same PR.
  • Loading branch information
sandersn committed Aug 29, 2022
1 parent c69ad1e commit 34ce0f9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions types/three/examples/jsm/nodes/shadernode/ShaderNode.d.ts
Expand Up @@ -82,10 +82,10 @@ type FilterConstructorsByScope<T extends AnyConstructors, S> = {
* "flattens" the tuple into an union type
*/
type ConstructorUnion<T extends AnyConstructors> =
| (T['a'] extends undefined ? never : T['a'])
| (T['b'] extends undefined ? never : T['b'])
| (T['c'] extends undefined ? never : T['c'])
| (T['d'] extends undefined ? never : T['d']);
| Exclude<T['a'], undefined>
| Exclude<T['b'], undefined>
| Exclude<T['c'], undefined>
| Exclude<T['d'], undefined>;

/**
* Extract list of possible scopes - union of the first paramter
Expand Down

0 comments on commit 34ce0f9

Please sign in to comment.