Search code examples
typescriptreact-number-format

react-number-format: JSX element type 'NumericFormat' does not have any construct or call signatures


I'm using react-number-format v5.4.0 with TypeScript and have installed the package using npm. However, I'm getting the error:

JSX element type 'NumericFormat' does not have any construct or call signatures.

which is highlighted under NumericInput in VsCode.

Here is a reproducible example:

import NumericFormat from 'react-number-format';

export default function CurrencyInput(){
  return (
    <NumericFormat />
  );
}

How do I fix this error?


Solution

  • I was able to get rid of the error by creating a module.d.ts file in my src directory with the following contents:

    declare module "react-number-format";