Natesh bhat
Natesh bhat

Reputation: 13192

How to get typescript for electron.js file when using create-react-app

In all the articles that explain how to use create-react-app with electron (eg : https://www.codementor.io/randyfindley/how-to-build-an-electron-app-using-create-react-app-and-electron-builder-ss1k0sfer ) , they mention that electron.js file should be placed within public folder.

I want to have typescript definitions for this electron.js too (since i am using typescript for the react app also). How do I do this ?

Upvotes: 0

Views: 596

Answers (1)

JAMESSTONEco
JAMESSTONEco

Reputation: 2051

I have spent quite a bit of time working on an electron project as well as creating a starter kit for using Electron + TypeScript (very strict) + Create React App (non-ejected). I think you might find it useful as a starting point, even though there might be some additional tooling that you might not need.

Check out the electron branch of Foldable for more details. Of particular interest would be src/electron.ts, package.json and the public dir.

To quickly give you some additional points that might be useful in your question:

  1. One can configure the entry script for Electron in your package.json under "main"
  2. You will need to use TSC or another typescript compiler to handle the "main-thread" or node portion of Electron. This is separate from CRA. Alternatively you can use plain javascript for a simpler setup.
  3. The only thing in my public folder is the html file minus the javascript imports (because they are injected automatically)

Upvotes: 2

Related Questions