paypal-js icon indicating copy to clipboard operation
paypal-js copied to clipboard

[Bug] Typescript warning: `resetOptions` cannot be used in dispatch type

Open TheMikeyRoss opened this issue 1 year ago • 1 comments

Library used

react-paypal-js

🐞 Describe the Bug

Typescript warning that resetOptions cannot be used as a dispatch type

image

🔬 Minimal Reproduction

Describe steps to reproduce. If possible, please, share a link with a minimal reproduction.

😕 Actual Behavior

A clear and concise description of what is happening. Please include console logs during the time of the issue, especially error messages.

🤔 Expected Behavior

A clear and concise description of what you expected to happen.

🌍 Environment

  • Node.js/npm: -
  • OS: -
  • Browser: -

➕ Additional Context

Add any other context about the problem here.

TheMikeyRoss avatar Jun 17 '24 14:06 TheMikeyRoss

This may be because we are using TypeScript's enum feature for those values.

Try using this:

import { DISPATCH_ACTION } from "@paypal/react-paypal-js";
...
dispatch({type: DISPATCH_ACTION.RESET_OPTIONS, ... })

wsbrunson avatar Jun 24 '24 15:06 wsbrunson

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Sep 23 '24 00:09 github-actions[bot]

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information.

github-actions[bot] avatar Sep 30 '24 00:09 github-actions[bot]

Same happened, after renegerating the package-lock file.

pablojsx avatar Jan 20 '25 18:01 pablojsx

TS warnings cleared out after doing this: import { usePayPalScriptReducer, DISPATCH_ACTION } from '@paypal/react-paypal-js';

dispatch({ type: DISPATCH_ACTION.RESET_OPTIONS, value: { clientId: paypal.clientId, currency: 'USD', }, });

MeriDev avatar Apr 06 '25 20:04 MeriDev