credit-card-type icon indicating copy to clipboard operation
credit-card-type copied to clipboard

Fix incorrect typings

Open uPaymeiFixit opened this issue 2 years ago • 2 comments

The README shows an addCard example that uses a pattern not currently valid with the CreditCardType.patterns type.

[number[]] should be number[][]

This accurately represents credit-card-type's pattern functionality and allows the README example to work:

creditCardType.addCard({
  niceType: "Visa with Custom Nice Type",
  type: creditCardType.types.VISA,
  patterns: [41111, [44, 47]],
  gaps: [4, 8, 12],
  lengths: [13, 16, 19], // add support for old, deprecated 13 digit visas
  code: {
    name: "CVV",
    size: 3,
  },
});

uPaymeiFixit avatar Jul 22 '22 02:07 uPaymeiFixit

👋 @uPaymeiFixit thanks for the PR! We'll take a look and provide feedback or merge, unfortunately I can't provide an ETA. For internal reference, ticket 1890

hollabaq86 avatar Aug 22 '22 21:08 hollabaq86

In case it helps, this is the code I'm currently using as a workaround. When this type definition is fixed the as any should be able to be removed. Please reach out if I can provide any more context.

    CardValidator.creditCardType.addCard({
      niceType: 'Deprecated 13 Digit Visa',
      type: 'visa-deprecated',
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
      patterns: [41111, [44, 47]] as any, // Required until this gets merged: https://github.com/braintree/credit-card-type/pull/147
      gaps: [4, 8, 12],
      lengths: [13, 16, 19], // add support for old, deprecated 13 digit visas
      code: {
        name: 'CVV',
        size: 3,
      },
    });

uPaymeiFixit avatar Sep 03 '22 18:09 uPaymeiFixit