typescriptnode-modulesbrightcove

How can I ignore implicitly any type when importing js module?


I am trying to import this @brightcove/react-player-loader package into my typescript project but its not running due to type error. enter image description here

I have tried overriding the module type in my custom.d.ts file like this but I couldnt get it to work:

import '@brightcove/react-player-loader';

declare module '@brightcove/react-player-loader' {
  var x: any;
  export = x;
}

I get this error: enter image description here

Any ideas how can I resolved this error? Thanks


Solution

  • I actually ran into this same error recently as well.

    You can create a declaration file that fixes the error by doing the following:

    1. Create an index.d.ts file in the root of your project
    2. Add declare module "@brightcove/react-player-loader"; to the first line of the file
    3. In your tsconfig.json file, in the "include" section, make sure you have an entry for .d.ts files, e.g.:
      "include": ["next-env.d.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.d.ts"]
      

    This should get rid of the error you are experiencing.