Reputation: 1471
I am starting to learn Typescript and so far so good when types are available to me to download. However, I have a javascript file that doesn't have its matching typescript and I would like to create my own one but I don't know how to do it or where to start.
The JS in question comes from https://docs.pci-proxy.com/inline-payment-frames.html and it is available at this url: https://pay.sandbox.datatrans.com/upp/payment/js/datatrans-inline-1.0.0.js
Could someone help me to create a basic TypeScript file that allows me to at least call the this.initTokenize function? The rest of tunctions are pretty similar so I should be able to mimic same logic by myself and learn from the example.
Thanks!
Upvotes: 3
Views: 4636
Reputation: 276239
How to generate a index.d.ts file from a Javascript file
Compile the JavaScript using TypeScript with options declaration: true, allowJs: true
. You will get a new .js
and .d.ts
file 🌹
Alternatively use the JavaScript as is with just allowJs: true
in your project.
Upvotes: 3