Skip to content

Instantly share code, notes, and snippets.

@doug
Created March 23, 2017 15:27
Show Gist options
  • Save doug/f447aa01fddc19a415aa740a7304ddd1 to your computer and use it in GitHub Desktop.
Save doug/f447aa01fddc19a415aa740a7304ddd1 to your computer and use it in GitHub Desktop.
Dynamically get the type of a deeply nested function in typescript.
function myfunc(): number {
return 42;
}
const tmp = (false as true) && myfunc();
type MyType = typeof tmp; // MyType is correctly number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment