G-Rath / electron-forge-webpack-ts-starter

A ready-to-go electron application that uses typescript, that can be used as a starting point for projects.
5 stars 1 forks source link

errors running npm run check:main #3

Open kzimny opened 5 years ago

kzimny commented 5 years ago

Thank you for your excellent example! I can start the application running npm start, but for some reason when I run npm run check:main the following errors are thrown:

c:\temp\angular\electron-forge-webpack-ts-starter>npm run check:main

> electron-forge-webpack-ts-starter@0.0.0 check:main c:\temp\angular\electron-forge-webpack-ts-starter
> tsc --noEmit -p ./src/main

node_modules/electron/electron.d.ts:8:20 - error TS2304: Cannot find name 'Event'.

8 type GlobalEvent = Event;
                     ~~~~~

node_modules/electron/electron.d.ts:6683:32 - error TS2304: Cannot find name 'HTMLElement'.

6683   interface WebviewTag extends HTMLElement {
                                    ~~~~~~~~~~~

node_modules/electron/electron.d.ts:6860:38 - error TS2304: Cannot find name 'HTMLElementEventMap'.

6860     addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
                                          ~~~~~~~~~~~~~~~~~~~

node_modules/electron/electron.d.ts:6860:85 - error TS2304: Cannot find name 'HTMLElement'.

6860     addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
                                                                                         ~~~~~~~~~~~

node_modules/electron/electron.d.ts:6860:102 - error TS2304: Cannot find name 'HTMLElementEventMap'.

6860     addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
                                                                                                          ~~~~~~~~~~~~~~~~~~~

node_modules/electron/electron.d.ts:6861:46 - error TS2304: Cannot find name 'EventListenerOrEventListenerObject'.

6861     addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/electron/electron.d.ts:6862:41 - error TS2304: Cannot find name 'HTMLElementEventMap'.

6862     removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
                                             ~~~~~~~~~~~~~~~~~~~

node_modules/electron/electron.d.ts:6862:88 - error TS2304: Cannot find name 'HTMLElement'.

6862     removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
                                                                                            ~~~~~~~~~~~

node_modules/electron/electron.d.ts:6862:105 - error TS2304: Cannot find name 'HTMLElementEventMap'.

6862     removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void;
                                                                                                             ~~~~~~~~~~~~~~~~~~~

node_modules/electron/electron.d.ts:6863:49 - error TS2304: Cannot find name 'EventListenerOrEventListenerObject'.

6863     removeEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
                                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 10 errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron-forge-webpack-ts-starter@0.0.0 check:main: `tsc --noEmit -p ./src/main`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron-forge-webpack-ts-starter@0.0.0 check:main script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Krzysztof\AppData\Roaming\npm-cache\_logs\2019-06-13T07_10_43_426Z-debug.log

What I'm missing?

G-Rath commented 5 years ago

@kzimny thanks for reporting this. I wrote this package quite a while ago; since then I've learnt a fair bit more about how to properly setup typescript :)

I'll have a look over this repo tonight, and see about cleaning it up a bit; in particular:

I'll make sure it compiles correctly this time 😉

You should still be able to run the application just fine, via npm start.

kzimny commented 5 years ago

Thank you, I'll check the changes. Inspired by your repo I tried to get work electron-forge + typescript + typeorm + sqlite3 libraries. May I kindly ask you to take a look at my problem? My project works correct in development mode, as soon as electron-forge compile to package for production the native modules libraries typeorm and sqlite are not copied to node_modules folder and the start fails. I described my problem in electron-forge repository at https://github.com/electron-userland/electron-forge/issues/935 but did not get any answer (yet). Do you have an idea how to get the solution work with electron-package command? You can clone the branch electron-forge-6 https://github.com/kzimny/electron-typescript-sqlite3-typeorm/tree/electron-forge-6 and it should work with any issues. Any hint is very appreciated. Thank you very much.

G-Rath commented 5 years ago

I can have a quick look, but no promises.

I've not worked w/ electron for a long time, and never actually compiled a project for publishing. I've tried to update this repo, but everything seems to have already changed a lot - My advice is to wait for v6 to be released to use webpack (which is sad).

As an example: I tried switching the configs to .ts, which Webpack natively supports (via ts-node), but completely failed here, which indicates to me electron-forge is for some reason modifying something w/ how native webpack works.

In saying that, personally I'd recommend looking into using lokijs instead of sqlite3. It's a lot faster, can persist to disk, and is pure JS. I've been doing my best to avoid sqlite3 for years b/c of the fact that it uses native modules, for this very reason; they're very easy to break :(

kzimny commented 5 years ago

Thank you for the link, yes I'll have a look at lokijs database. I'm not sure if lokijs meets my project requirements. My customer should save thousands of images in the database... Yes no joke.

G-Rath commented 5 years ago

I mean, I'd question why they have to do that - a far better way would be to just save the images to disk next to the database, and then store the filename where you'd store the image.

There's no advantage to storing images in the database, vs using a key to map to the image on disk; i.e theres no compression, no advance image querying you can do if they're in there, etc.

Eitherway, LokiJS will be able to handle that; in fact it'd do it better than sqlite3, b/c it's pure Javascript.