how to map TypeScript union types
See original GitHub issueHi, how can we map TypeScript union types in kotlinjs ?
For example in ReactQuery there are signatures like this:
queryClient.setQueryData(queryKey, updater)
queryKey: QueryKey
updater: TData | (oldData: TData | undefined) => TData
(I asked ReactQuery to avoid such signatures: https://github.com/TanStack/query/issues/3740 )
Issue Analytics
- State:
- Created a year ago
- Comments:6
Top Results From Across the Web
TypeScript: Map union type to another union type
You can use conditional type for distributing over the members of the union type (conditional type always takes only one branch and is...
Read more >Map over a union type | Total TypeScript
TypeScript actually automatically maps over each member of the union when it's doing a conditional type check.
Read more >Creating a mapped type | Learn TypeScript
A mapped type is the process of creating a new type by mapping type ... The in operator maps over each item in...
Read more >How to make a map object type from a union type in TypeScript?
To make a simple map object type from a union type, you can use the in operator in combination with Index Signature syntax...
Read more >Documentation - Mapped Types - TypeScript
You can map over arbitrary unions, not just unions of string | number | symbol , but unions of any type: ts. type...
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 Free
Top 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
@frhack You can close it as author (and others, which solved for you)
Indeed the provided signature is more general and so to pass a simple value I just passed a lambda that returns that value
I got an answer from ReactQuery team:
https://github.com/TanStack/query/issues/3740