I want to use an payment system which is calling iyzico. The iyzico payment library is https://www.npmjs.com/package/iyzipay it. But there is not any types so how can i use this library on my node.js typescript express backend project?
i tried make one mylib.d.ts file on my root directory and put this code on this file.
declare module 'iyzipay';
After then i put this variable on my tsconfig.json file
,"include": [
"src", "mylib.d.ts"
]
When i import the libary on my project i get an error like this.
Could not find a declaration file for module 'iyzipay'. '/Users/xxx/node_modules/iyzipay/lib/Iyzipay.js' implicitly has an 'any' type. Try
npm i --save-dev @types/iyzipay
if it exists or add a new declaration (.d.ts) file containing `declare module 'iyzipay';
You need to declare export types for module 'iyzipay';
For example:
declare module 'iyzipay' {
interface IyzipayOptions {
apiKey: string;
secretKey: string;
uri: string;
}
class Iyzipay {
constructor (options: IyzipayOptions);
}
export default Iyzipay;
}
This type declaring is just for the simple usage from document. You should write the types as you need.
import Iyzipay from 'iyzipay';
var iyzipay = new Iyzipay({
apiKey: 'your api key',
secretKey: 'your secret key',
uri: 'https://sandbox-api.iyzipay.com'
});