The Problem
When you try to copy the type directly from the inferred VS Code type, you get this shortened version which do not include all the details.
The Solution
The solution is quite simple and will use tsc
.
First of all, be sure that you do not have any types defined in the file from the beginning. Then run the following script.
tsc filename.ts --declaration --emitDeclarationOnly
This will create a file with the full definition. Simple as that.
If you haven’t installed tsc
you can choose to either use npx
or install it globally.
# install if before running the command
npm install typescript -g
# or run it with npx
npx tsc filename.ts --declaration --emitDeclarationOnly