0

trying to use TS with latest Electron 9.0.3. I renamed main.js to main.ts, and adjusted "main" value in package.json to use main.ts.

The main.ts file does get transpiled and works, but it seems Electron 9 does not fully support TS, as I get errors when declaring types, for example:

function my_function(str: string)
{
   // do something
}

will break the app, complaining about the ": string" type declaration...

Is there another setting/config that I'm missing ?

1 Answer 1

2

Electron never supported run typescript file directly and never will. You have to supply .js file transpiled from typescript to electron instead of pointing typescript file directly.

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

2 Comments

could you elaborate on how to do that exactly ?
The main entry point that Node.js will execute is provided in the package.json file. Make sure it points to the transpiled ECMAScript file, not the TypeScript source file. Node.js doesn't support TypeScript, so every entry point you provide in the package.json file must always be ECMAScript.

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.