react-plaid-link icon indicating copy to clipboard operation
react-plaid-link copied to clipboard

Avoid `object`, `Function`, `any`, and `as T` type declarations, fix `exit()` arg type

Open mmcgahan opened this issue 1 year ago • 0 comments

This is an update to the type definitions in order to improve type safety and make the library a little easier to use in downstream TypeScript applications.

  1. object, Function, and any type declarations are extremely permissive, and can broaden the accepted and returned types to the point where they are effectively untyped
    • https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#any
    • https://www.typescriptlang.org/docs/handbook/2/functions.html#function
    • object means "any non-primitive type"
  2. Using type assertions (e.g. foo as Bar) can be dangerous because the value might not actually match the asserted type. Instead, we can use type guards to programmatically narrow the type based on a type predicate that we define.
  3. The type declaration for the returned exit method was not correct - it has been fixed to match exitOptions expected by Plaid.create().exit(exitOptions)

mmcgahan avatar Sep 25 '23 01:09 mmcgahan