3

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!

5

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Combining the declaration and allowJs flags is not allowed. Doing so results in the message error TS5053: Option 'allowJs' cannot be specified with option 'declaration'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.