JavaScript doesn't always contain enough type information for the TypeScript compiler to infer the structures in your code - so automatically generating a definition based on JavaScript is rarely an option.
There are instructions on how to write them from scratch here:
https://www.stevefenton.co.uk/2013/01/complex-typescript-definitions-made-easy/
But there is one trick that might work (it only works in a limited set of cases).
If you paste the JavaScript into a new TypeScript file, fix any trivial errors you may get and compile it using the definition flag, it may be able to get you a file that would at least be a starting point.
tsc --declaration js.ts
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…