Open farfromrefug opened 8 years ago
What problems specifically are you running into?
My typescript files don't seem to be compiled, even with electron-compilers
. I get some cannot parse errors (sorry don't have the exact log right now).
I think a boilerplate with typescript, even react typescript, would be great.
I'm the same way.
I've installed Typings and electron
/node
as globalDependencies. My file looks like this:
{
"name": "example-starter",
"dependencies": {},
"globalDependencies": {
"electron": "registry:env/electron#0.37.6+20160723033700",
"node": "registry:dt/node#6.0.0+20160807145350"
}
}
The first two lines of my index.ts file look like:
import { app, autoUpdater, BrowserWindow } from 'electron';
import * as os from 'os';
...And I'm getting the following error:
App threw an error during load Error: L0: File 'electron.ts' is not a module. L1: File 'os.ts' is not a module.
What am I doing wrong? Do I need a .tsconfig.json
file? If so, what should I put in it?
@aendrew You need to install electron-prebuilt-compile
as a dependency, and use that instead of the global electron
binary. electron-prebuilt-compile
wraps Electron with electron-compile
, which is what lets you use TypeScript out of the box.
And what do you import into your main.ts (Typescript) file? Neither electron-compile nor electron-prebuilt-compile come with typings and there are non available via npm install @types/...
Documentation on electron-compile is really bad.
I agree, better documentation is needed. I am having the same issues with typescript. Imports are not working for me either, getting such_and_such.ts is not a module errors too.
There still is no TypeScript example; am posting to prevent probot-stale
from closing.
am posting to prevent probot-stale from closing.
Sorry about that, @aendrew. It was an accident. Didn't mean to mark this issue as wontfix
.
@zeke It's cool! It's just probot doing it's probot-y thing. 😄
Is there a typescript example yet?
My asar's main folder contains both generated .js files and the original .ts files that generated them. The *.ts files are causing javascript exceptions (on the import lines, but I suspect that's just because they are at the front of the files and I suspect any typescript syntax in the files would cause problems if I were to somehow fix the import issue).
I think I what I need to do is exclude the main .ts files from being included in the asar but I can't figure out how to do that without also excluding the renderer .ts files that the app I think needs to have included in the build process (I can't actually tell if the renderer *.ts files are required because I hit errors before I get there).
The app runs fine when running in development mode, its just when I try to build an actual executable that I hit these problems.
[edit: added] If I temporarily delete all the main .ts files (keeping the renderer .ts files intact) the app builds and runs correctly, so the issue is how to prevent the main .ts files from getting copied into the asar without preventing the renderer .ts files from going there or preventing the main .ts files from getting loaded out of the asar by main without preventing the renderer .ts files from getting loaded (and note that I don't currently share any *.ts files between main and renderer so for my case it's theoretically the simplest case, I think)
I have a minimal working example over here: https://github.com/danzel/electron-compile-builder-typescript-example
Took me ages to figure out, please enjoy.
It doesn't use electron-prebuilt-compile
, I couldn't get it to work when building, only in dev.
Neither electron-compile nor electron-prebuilt-compile come with typings and there are non available via npm install @types/...
This pretty much sums up the entire problem for me right now. b/c the electron typings are not published to @types
, they can't be installed independently of electron itself, which we have to replace with electron-compile
, which for some reason decides not to pull the typing in from electron.
Now, this is fine from electron-compile
s end, as it will compile fine, but it breaks external typescript, meaning that running tsc
results in an error. This is important, as it means ides (such as WebStorm) that rely on the ts service also break.
This is why it's always better to publish typings to @types
rather than inline them with your package. Can electron-compile
please be updated to resolve this issue?
Either:
electron
, orelectron
into electron-compile
Hi,
I am having a really hard time getting this to work with typescript. Could you create a boilerplate example? Maybe even with the main script being a typescript file.
Thanks