react-plaid-link
react-plaid-link copied to clipboard
Avoid `object`, `Function`, `any`, and `as T` type declarations, fix `exit()` arg type
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.
-
object
,Function
, andany
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"
- 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. - The type declaration for the returned
exit
method was not correct - it has been fixed to matchexitOptions
expected byPlaid.create().exit(exitOptions)