react-currency-input-field icon indicating copy to clipboard operation
react-currency-input-field copied to clipboard

Bug - incorrect TS typings of CurrencyInput component

Open Git-I985 opened this issue 1 year ago • 0 comments

Issue

Im using typescript + next.js, during the app build - this message occurs:

./node_modules/react-currency-input-field/src/components/CurrencyInput.tsx:24:14
Type error: Type 'ForwardRefExoticComponent<Omit<CurrencyInputProps, "ref"> & RefAttributes<HTMLInputElement>>' is not assignable to type 'FC<CurrencyInputProps>'.
  Types of property 'propTypes' are incompatible.
    Type 'WeakValidationMap<Omit<CurrencyInputProps, "ref"> & RefAttributes<HTMLInputElement>> | undefined' is not assignable to type 'WeakValidationMap<CurrencyInputProps> | undefined'.
      Type 'WeakValidationMap<Omit<CurrencyInputProps, "ref"> & RefAttributes<HTMLInputElement>>' is not assignable to type 'WeakValidationMap<CurrencyInputProps>'.
        Types of property 'ref' are incompatible.
          Type 'Validator<LegacyRef<HTMLInputElement> | undefined> | undefined' is not assignable to type 'Validator<((instance: HTMLInputElement | null) => void) | RefObject<HTMLInputElement> | null | undefined> | undefined'.
            Type 'Validator<LegacyRef<HTMLInputElement> | undefined>' is not assignable to type 'Validator<((instance: HTMLInputElement | null) => void) | RefObject<HTMLInputElement> | null | undefined>'.
              Type 'LegacyRef<HTMLInputElement> | undefined' is not assignable to type '((instance: HTMLInputElement | null) => void) | RefObject<HTMLInputElement> | null | undefined'.
                Type 'string' is not assignable to type '((instance: HTMLInputElement | null) => void) | RefObject<HTMLInputElement> | null | undefined'.

  22 | } from './utils';
  23 |
> 24 | export const CurrencyInput: FC<CurrencyInputProps> = forwardRef<
     |              ^
  25 |   HTMLInputElement,
  26 |   CurrencyInputProps
  27 | >(

Versions

react-currency-input-field 3.8.0
@types/react 18.2.61
@types/react-dom 18.2.19

tsconfig.json in my project

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {  /* my paths aliases here */ }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["**/*.spec.ts", "node_modules"]
}

Additional comments

Issue occurs on @types/react version 18.2.61, I rolled back @types/react version to 18.2.18 and error is gone

Git-I985 avatar Mar 01 '24 16:03 Git-I985