Search code examples
angulartypescriptvisual-studio-coderefactoring

How to copy the inferred type of an untyped function (TypeScript) in Visual Studio Code when its very long


(See Screenshot) Screenshot of function when hovering with mouse

I have this function with a really long untyped object returned, I want to copy the inferred type of that object because it's way too long to do manually, and then I want to make class/interface of it, example:

export class PatientTables {
  emsf: string;
  cadNumber: string;
  // and so on
}

is there a way to copy it from somewhere as it seems Visual Studio Code already has it assorted somewhere, as you can see in the picture (48 more), how can I make it show the rest and copy it? thanks!


Solution

  • Right click the function name, choose "refactor", then "Infer function return type".