cawa-93 / vite-electron-builder

Secure boilerplate for Electron app based on Vite. TypeScript + Vue/React/Angular/Svelte/Vanilla
MIT License
2.4k stars 261 forks source link

Change `moduleResolution` to `node16` or `nodenext` #997

Closed raphaelmenges closed 3 months ago

raphaelmenges commented 6 months ago

Hello πŸ‘‹,

Thanks for this awesome template and the latest move to ESM. Great work so far!

When migrating my project to these latest changes I observed issues with the electron-store module. According to its maintainer, the .tsconfig of this template is not fully "ESM-compliant". They suggest to change the moduleResolution of the .tsconfig to node16 or nodenext. I have created a repository using this template to reproduce the problem: https://github.com/raphaelmenges/electron-store-type-error

The output of `npm run typecheck` is as follows: ```js $ npm run typecheck > vite-electron-builder@2.0.0 typecheck > npm run typecheck:main && npm run typecheck:preload && npm run typecheck:renderer > vite-electron-builder@2.0.0 typecheck:main > tsc --noEmit -p packages/main/tsconfig.json packages/main/src/store.ts:5:7 - error TS2339: Property 'set' does not exist on type 'ElectronStore>'. 5 store.set('unicorn', 'πŸ¦„'); ~~~ packages/main/src/store.ts:6:19 - error TS2339: Property 'get' does not exist on type 'ElectronStore>'. 6 console.log(store.get('unicorn')); ~~~ packages/main/src/store.ts:10:7 - error TS2339: Property 'set' does not exist on type 'ElectronStore>'. 10 store.set('foo.bar', true); ~~~ packages/main/src/store.ts:11:19 - error TS2339: Property 'get' does not exist on type 'ElectronStore>'. 11 console.log(store.get('foo')); ~~~ packages/main/src/store.ts:14:7 - error TS2339: Property 'delete' does not exist on type 'ElectronStore>'. 14 store.delete('unicorn'); ~~~~~~ packages/main/src/store.ts:15:19 - error TS2339: Property 'get' does not exist on type 'ElectronStore>'. 15 console.log(store.get('unicorn')); ~~~ Found 6 errors in the same file, starting at: packages/main/src/store.ts:5 ```
cawa-93 commented 6 months ago

PR welcome

raphaelmenges commented 3 months ago

@cawa-93 can you have a look at the PR? πŸ‘‰πŸ‘ˆ

I am really interested in your opinion on how to handle the .js extension decision!