styletron / styletron

:zap: Toolkit for component-oriented styling
https://www.styletron.org
MIT License
3.32k stars 98 forks source link

Cannot use DebugEngine with Typescript #337

Open koukalp opened 5 years ago

koukalp commented 5 years ago

I am following the documentation when setting up this awesome library with React and Typescript.

  1. Import the dependencies:

    import {Provider as StyletronProvider, DebugEngine} from "styletron-react";
  2. init the debugger:

    const debug = process.env.NODE_ENV === "production" ? void 0 : new DebugEngine();
  3. Typescript gives a warning on the new DebugEngine() image

  4. in step 1, import BrowserDebugEngine instead:

    import {BrowserDebugEngine,Provider as StyletronProvider} from "styletron-react";
  5. use it in step 2:

    const debug =process.env.NODE_ENV === "production" ? void 0 : new BrowserDebugEngine();
  6. React app won't load with the following error: image

The debug feature would be quite useful. Everything else works flawlessly. Would be great if smbd could give me a hint on how to fix my issue

choyongjoon commented 5 years ago

I'm using // @ts-ignore to ignore this error.

koukalp commented 5 years ago

thanks for answer. That doesn't really fix anything for me:

// @ts-ignore
  process.env.NODE_ENV === "production" ? void 0 : new BrowserDebugEngine();
chasestarr commented 5 years ago

This repo only maintains and publishes flow-types. I suggest sending a PR to DefinitelyTyped if you find it helpful