0

Trying to augment the React Module to include an interface to allow icons, below, to be a type of object.

import "react-app-polyfill/ie11"; // For IE 11 support
import "react-app-polyfill/stable";
import "core-js";
import "./polyfill";
import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import App from "./App";
import * as serviceWorker from "./serviceWorker";

import store from "./store";

import { icons } from "./assets/icons";

declare module "react" {
  interface icons {
    icons: object;
  }
}

React.icons = icons;

ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById("root")
);

serviceWorker.unregister()

Currently React.icons, line 21 is presenting the error Property 'icons' does not exist on type 'typeof import("/home/nickisyourfan/Desktop/DEV/OnDeBand/app/node_modules/@types/react/index.d.ts")'.

Without the module augmentation,

declare module "react" {
  interface icons {
    icons: object;
  }
}
```,
A similar error occurs: `Property 'icons' does not exist on type 'typeof React'.`

Any help is appreciated! 
Nick McLean
  • 601
  • 1
  • 9
  • 23
  • Would be better to work around removing `React.icons = icons` as some comments suggested you in https://stackoverflow.com/questions/66925353. – GG. Apr 02 '21 at 22:33
  • I see -- Should have edited that question. Is there a reason though, to not augment the module? – Nick McLean Apr 02 '21 at 22:38
  • Because adding properties to an imported module is a bad practice. I'm not even sure how that works. But as you can see it's the root of your issue. And there is probably no good reasons to do it. You should find every place where `React.icons` is used and replace it by `icons`. – GG. Apr 02 '21 at 23:11

0 Answers0