Issue
I am trying to import this @brightcove/react-player-loader package into my typescript project but its not running due to type error.
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;
}
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:
- Create an index.d.ts file in the root of your project
- Add declare module "@brightcove/react-player-loader"; to the first line of the file
- In your tsconfig.json file, in the "include" section, make sure you have an entry for .d.ts files.. example:
"include": ["next-env.d.ts", "/*.tsx", "/.js", "**/.jsx", "**/*.d.ts"]
This should get rid of the error you are experiencing. Hope this helps.
Answered By - Robert Farris
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.