The typeof
type operator
TypeScript adds a typeof
operator you can use in a type context to refer to the type of a variable or property:
If we try to use ReturnType
on a function name, we see an instructive error:
TypeScript intentionally limits the sorts of expressions you can use typeof
on.
// Meant to use = ReturnType<typeof msgbox>let',' expected.1005',' expected.shouldContinue : typeof"Are you sure you want to continue?"); msgbox (