79392220

Date: 2025-01-27 21:35:42
Score: 0.5
Natty:
Report link

It seems I have found the solution with the help of this answer:

type Foo = Record<string, any>;
type FuncGenericReturn<T> = () => T;

const untypedFunction = () => {
    const test = {};
    // ...
    return test;
}
const funcReturnsFoo: FuncGenericReturn<Foo> = untypedFunction;

const myObject = funcReturnsFoo(); // myObject is typed as Foo
Reasons:
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: AnJ