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

[Bug] Cannot Access HostedFieldsInstance.on() method without removing type #298

Closed
stefanmterry opened this issue Oct 28, 2022 · 0 comments · Fixed by #299
Closed

[Bug] Cannot Access HostedFieldsInstance.on() method without removing type #298

stefanmterry opened this issue Oct 28, 2022 · 0 comments · Fixed by #299

Comments

@stefanmterry
Copy link

🐞 Describe the Bug

The return type from HostedFields.render() does not include the on() function to access field event subscription. It must by type-casted as "any" to avoid typescript errors.

🔬 Minimal Reproduction

In the .then callback from a HostedFields.render() function, try to access the .on() function:

loadScript({
...
}).then(
  (paypal) => {
    paypal.HostedFields.render({
      ...
    }).then(
      (cardFields) => {
          cardFields.on('validityChange', (event) => { ... });
      }
    )
  }
)

throws an "method on() does not exist on type HostedFieldsHandler" error

...
.then(
  (cardFields) => {
    (cardFields as any).on('validityChange', (event) => { ... });
  }
)

subscribes to the event just fine.

😕 Actual Behavior

The interface is missing declarations for the .on() subscription method.

🤔 Expected Behavior

The interface includes all method calls available through the Paypal API

🌍 Environment

  • Node.js/npm: - 6.14.15
  • OS: - Ubuntu 20.04.5
  • Browser: - Chrome

➕ Additional Context

While not a critical breaking issues, as it's easily worked around, it was definitely a source of confusion.

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 a pull request may close this issue.

1 participant