React-ga: Cannot find namespace 'React'.

Created on 10 Jan 2018  路  4Comments  路  Source: react-ga/react-ga

Error happens because of this line: https://github.com/react-ga/react-ga/blob/master/types/index.d.ts#L74.

I think you must add @types/react as a (peer or normal) dependency and than add import * as React from 'react'; or so to your index.d.ts.

bug good first issue

Most helpful comment

I see that this line has been added:

import * as React from 'react';

I can see this in the master branch at /types/index.d.ts but when I download the module I don't see this change. Can you please draft a new release with this change. I'm trying to use this in a Typescript React application. Thanks a lo!

All 4 comments

Can you do a PR for this? I don't actively use TS so I rely on PR's for this.

I believe this involves either generating declaration file programmatically to incorporate needed React types, which requires some setup changes, or setting @types/react as a peerDependency, which is bad for non-typescript users.
Maybe a good first step is to add a typescript section to the getting started docs and specifying that npm i @types/react is required

I see that this line has been added:

import * as React from 'react';

I can see this in the master branch at /types/index.d.ts but when I download the module I don't see this change. Can you please draft a new release with this change. I'm trying to use this in a Typescript React application. Thanks a lo!

npm install @types/react worked for me. Thanks @donaldpipowitch

Was this page helpful?
0 / 5 - 0 ratings

Related issues

astroana picture astroana  路  5Comments

nicolasiensen picture nicolasiensen  路  7Comments

horaceleung picture horaceleung  路  6Comments

dirtyredz picture dirtyredz  路  7Comments

Dimomir picture Dimomir  路  3Comments