typescriptpayment-request-api

TypeScript and canMakePayment


I'm trying to make a system that uses the Payment Request Api and for the most part its successful, but TypeScript doesn't seem to have a definition for canMakePayment under the PaymentRequest object.

Am I missing something or do I need to cast it to any so my Typescript builds?

Thanks


Solution

  • I would recommend writing a small .d.ts file and reference that while the library type definitions do not include the complete interface yet.

    i.e. containing something like:

    declare interface PaymentRequest
    {
        canMakePayment(): boolean; // Or whatever the correct type signature is.
    }
    

    If you place it in an @types directory it might be picked up automatically. Else use a reference comment, e.g. /// <reference path="payment-request-extension.d.ts" />.