syntax to control over distributivness
See original GitHub issuefrom: https://github.com/Microsoft/TypeScript/issues/30569#issuecomment-476007534
so basically we need a way to say it clear and loud in the language whether we want:
Promise<A> | Promise<B>
or
Promise<A | B>
as a result of a type operation
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:12 (2 by maintainers)
Top Results From Across the Web
Possible regression in 3.4 with distributive conditional types
Using the distributive behavior of conditional types, UnionKeys gets the union of keys in each member of the union and the result is...
Read more >The distribution syntax for random values—ArcMap
The following describe the syntax for the different available distributions for the various random tools: UNIFORM {Minimum}, {Maximum}—A uniform distribution ...
Read more >Distribution keys - IBM® Netezza
You can use the following Netezza SQL command syntax to create tables and specify distribution keys: To create an explicit distribution key, the...
Read more >The Normal Distribution and Control Charts
You are the manager at a new toy store and want to determine how many Monopoly games to stock in you store. The...
Read more >User controlled unnormalized (propto) distribution syntax ...
The sampling statement form (with ~ ) drops normalizing constants in the samplers and optimizers. Based on the poll done in the linked...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
(Unexpected) Distributivity of conditional types is something that bit me fairly strongly today, the fact some features are just magically distributive seems fairly confusing design in my opinion.
Like the main reason distributivity is wanted is so that people can specify things like
Boxed<a | b> === Box<a> | Box<b>
, but that seems more of a failure of the language to provide a way to specify a list of types to be distributed later.Consider arrays,
Array<A | B>
is notArray<A> | Array<B>
, the fact some generics just magically distribute seems more of an confusing feature than a predictable one. It’d be more obvious if there was just a way to declare a distributed union for any generic, i.e. maybeArray<A || B> === Array<A> | Array<B>
. People then wouldn’t even need to define the wrappers, they could just||
wherever they want spreading over a type constructor.Tuples do have special treatment in that they correctly create substitution types in the true branch, effectively doing type narrowing—an object type will not do that. This is why the tuple method is proposed as the canonical way of doing this.
Very much agree.