question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do you reference a typescript file in an Electron app?

See original GitHub issue
  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Please describe your issue:

Could someone help me to setup a blank Electron project to use TypeScript and nothing else?

The React + TypeScript template is almost exactly what I would like however I don’t understand one piece of this template.

I removed all the React parts (since I will not be using it) but that leaves me with the one html file and one index.ts file. The index.ts file starts up the Main thread used by electron which is great, but I also want to write all my Renderer thread code in TypeScript too.

The part that I don’t understand is how do I add my Renderer.ts file to the mix? I need the TypeScript compiler to compile this (and additional files) and I need to somehow access this code in the index.html file. I’m not sure how electron-forge knows which typescript files to compile, and I do not understand where the compiled files get placed. How do I access Renderer.ts in the html file?

Console output when you run electron-forge with the environment variable DEBUG=electron-forge:*. (Instructions on how to do so here). Please include the stack trace if one exists.

Put the console output here

What command line arguments are you passing?

Put the arguments here

What does your config.forge data in package.json look like?

Paste the config.forge JSON object here

Please provide either a failing minimal testcase (with a link to the code) or detailed steps to reproduce your problem. Using electron-forge init is a good starting point, if that is not the source of your problem.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
maleptcommented, Mar 26, 2018

FWIW Webpack support will be in Electron Forge v6.

0reactions
mulgurulcommented, Dec 21, 2020

I’m giving ip on Electron-forge as well. It should make everything easy so you could focus on building your app. Not! spent 2 days on trying to get the app to load static content like images from html using webpack, and no luck. The documentation is so lousy, everything is described so briefly, like you should know everything yourself… So really, it does only complicate things a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do you reference a typescript file in an Electron app? #457
So, all you need to do is add a <script> tag referencing the TypeScript file, and Forge (really, electron-compile) will compile it on...
Read more >
TypeScript and Electron The Right Way | by Dave Bush
You'll need to compile the TypeScript into JavaScript so that Electron will be able to run your files. But before we do this,...
Read more >
How to get typescript for electron.js file when using create ...
You will need to use TSC or another typescript compiler to handle the "main-thread" or node portion of Electron. This is separate from...
Read more >
Typescript + Electron = - YouTube
Hello Everyone ! Today I will be creating a secure TypeScript application using NodeJS/ Electron / HTML and CSS.
Read more >
Announcing TypeScript support in Electron
The electron npm package now includes a TypeScript definition file that provides detailed annotations of the entire Electron API.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found