braintree / credit-card-type

A library for determining credit card type
MIT License
980 stars 154 forks source link

Fix incorrect typings #147

Open uPaymeiFixit opened 2 years ago

uPaymeiFixit commented 2 years ago

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,
  },
});
hollabaq86 commented 2 years ago

👋 @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

uPaymeiFixit commented 2 years ago

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,
      },
    });