2

So it looks like with newer electrons you can just start it off in typescript right away with

electron main.ts

  1. Though you can't do electron ./main and you'd still need to require('./file.ts').
  2. And I noticed that when I build it the .exe still complains that it needs a main.js file.

How can I solve these two issues without going with a compiler (just load typescript directly)?

2 Answers 2

1

You can use TypeScript Execute (tsx) to execute typescript in electron now.

npm scripts "start:main": "NODE_OPTIONS=\"--import tsx\" electron ./src-main/main.ts",

Sign up to request clarification or add additional context in comments.

Comments

0

Electron is not supposed to execute TypeScript code directly so you have to convert it to Javascript before to be able to use it in electron. By the way here a useful link to refer: https://www.electronjs.org/blog/typescript

Please refer also to this question: How to add my own typescript classes in Electron project

1 Comment

Thanks, that's a bit of a let down really, if electron executes typescript seemlessly that would've been ideal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.