decltypein C ++ returns the type of expression, for example it decltype(1+1)will int.
Note that the expression will not be executed or compiled.
Does Typescript have something like this?
An example usecase that I think should work:
const foo = () => ({a: '', b: 0});
type foo_return_type = decltype(foo());
import { bar } from './some_module';
type my_type = decltype(new bar().some_method());
source
share