react-gtm
react-gtm copied to clipboard
support TypeScript
it doesn't support..
Try npm install @types/react-gtm-module if it exists or add a new declaration (.d.ts) file containing declare module 'react-gtm-module';
It doesn't exist at this moment. It's required to use declare module 'react-gtm-module';.
declare module 'react-gtm-module worked for me
I wrote some basic types which I published using the DefinitelyTyped repo, take a look: https://www.npmjs.com/package/@types/react-gtm-module
somehow the typings don´t work for me. In the build it adds ".default" to the imported Tagmanager
eg.
When I have this in TS: TagManager.initialize(x)
the js-file results in: TagManager.default.initialize(x)
which (of course) results in an "Call-to-undefined" as there is no "default" in the TagManager object.
It only works, when i remove the typings and import it in that form: import * as GTM from "react-gtm-module";
What if we rewrite the app in TS? Would it be a good idea @alinemorelli ?
Rewrite in TS is not necessary, an update of the typings should be enought i think
It seems the typings have not been fixed. I'm getting the issue with the built code containing react_gtm_module_1.default.initialize(this.props.gtmArgs); default is undefined and therefore the app fails.
The tsx file has: TagManager.initialize(this.props.gtmArgs)
This is with "react-gtm-module": "2.0.11", "@types/react-gtm-module": "2.0.0",
@types/react-gtm-module version 2.0.1 seems to work fine for basic support at least ✅