TS2503

error TS2503: Cannot find namespace ‘React‘.

Broken Code ❌

1
export type CompositeComponent<P> = React.ComponentClass<P>;

Fixed Code ✔️

You have to add an import statement when reusing a different namespace. Also make sure to install type declarations (i.e. @types/react) if needed.

1
2
3
import React from 'react';

export type CompositeComponent<P> = React.ComponentClass<P>;

error TS2503: Cannot find name ‘process’. Do you need to install type definitions for node? Try npm i --save-dev @types/node.

Solution

Run yarn add --dev @types/node in your npm project.