react-gtm icon indicating copy to clipboard operation
react-gtm copied to clipboard

support TypeScript

Open shinriyo opened this issue 7 years ago • 8 comments

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';

shinriyo avatar Jul 09 '18 06:07 shinriyo

It doesn't exist at this moment. It's required to use declare module 'react-gtm-module';.

sigo avatar Jan 04 '19 12:01 sigo

declare module 'react-gtm-module worked for me

ChristianRich avatar Feb 24 '19 22:02 ChristianRich

I wrote some basic types which I published using the DefinitelyTyped repo, take a look: https://www.npmjs.com/package/@types/react-gtm-module

marcveens avatar May 27 '19 18:05 marcveens

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";

LeopoldLerch avatar Jul 15 '19 13:07 LeopoldLerch

What if we rewrite the app in TS? Would it be a good idea @alinemorelli ?

pedroapfilho avatar Jul 31 '19 12:07 pedroapfilho

Rewrite in TS is not necessary, an update of the typings should be enought i think

LeopoldLerch avatar Aug 05 '19 12:08 LeopoldLerch

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",

jamesdwork avatar Jun 09 '21 13:06 jamesdwork

@types/react-gtm-module version 2.0.1 seems to work fine for basic support at least ✅

aleksijohansson avatar Apr 03 '22 21:04 aleksijohansson