Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mmcgahan
Copy link

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
  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)

@@ -167,7 +167,7 @@ export type PlaidLinkPropTypes = PlaidLinkOptions & {

export interface PlaidHandler {
open: () => void;
exit: (force?: boolean) => void;
exit: (exitConfig?: { force?: boolean }) => void;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the fix to exit - you can see that exit expects an object rather than a boolean arg here https://github.com/plaid/react-plaid-link/pull/318/files#diff-399d91c5730fe8c956a45beb380a60404c1fcea16640f3a5f58b82e052aebfdaR77

@mmcgahan mmcgahan force-pushed the type-safety-improvements branch from 4394575 to f189e87 Compare September 25, 2023 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant