We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please follow the template and fill the info. A PR will be auto-generated and always reflect on your changes. Detailed solution/guide is not required, but please be sure the challenge is solvable.
Please follow the template and fill the info. A PR will be auto-generated and always reflect on your changes.
Detailed solution/guide is not required, but please be sure the challenge is solvable.
Basic info of your challenge questions,
difficulty: extreme title: Function Overload To Union tags: union, overload, function
Implement a type OverloadToUnion that transforms all overloads of a function into a union.
OverloadToUnion
type OverloadToUnion<F> = any;
Provide some test cases for your challenge, you can use some utils from @type-challenges/utils for asserting.
@type-challenges/utils
import type { Equal, Expect } from '@type-challenges/utils' import { ExpectFalse, NotEqual } from '@type-challenges/utils' type Tab = { id: number; url?: string; } declare function queryTab(callback: (user: Tab) => void): void; declare function queryTab(id: number): Tab; declare function queryTab(name: string): Promise<Tab>; type Details = { code?: string } type InsertCSSFunc = { (details: Details): Promise<void>; (details: Details, callback?: () => void): void; (tabId: number, details: Details): Promise<void>; (tabId: number, details: Details, callback?: () => void): void; } type cases = [ Expect<Equal<OverloadToUnion<typeof queryTab>, ((callback: (user: Tab) => void) => void) | ((id: number) => Tab) | ((name: string) => Promise<Tab>)>>, Expect<Equal<OverloadToUnion<InsertCSSFunc>, ((details: Details) => Promise<void>) | ((details: Details, callback?: (() => void) | undefined) => void) | ((tabId: number, details: Details) => Promise<void>) | ((tabId: number, details: Details, callback?: (() => void) | undefined) => void)> >, ]
The text was updated successfully, but these errors were encountered:
#20910 - Pull Request updated.
Sorry, something went wrong.
feat(question): add #20909 - Function Overload To Union
69e1852
Possible solution: Playground
Successfully merging a pull request may close this issue.
Info
Basic info of your challenge questions,
Question
Implement a type
OverloadToUnion
that transforms all overloads of a function into a union.Template
Test Cases
Provide some test cases for your challenge, you can use some utils from
@type-challenges/utils
for asserting.The text was updated successfully, but these errors were encountered: