Skip to content

Instantly share code, notes, and snippets.

@EduardoRFS
Created March 10, 2023 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EduardoRFS/32d452c20892727e24892dba5ea5e4ec to your computer and use it in GitHub Desktop.
Save EduardoRFS/32d452c20892727e24892dba5ea5e4ec to your computer and use it in GitHub Desktop.
const f = <
A extends "number" | "string",
T extends A extends "number" ? number : A extends "string" ? string : never
>(
_: A,
x: T
) => x;
const a = f("number", 1);
const b = f("string", "b");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment