caoxiemeihao / vite-electron-plugin

High-performance, esbuild-based Vite Electron plugin
MIT License
54 stars 7 forks source link

tsc failed to check: Property 'electronApp' does not exist on type 'Process' #29

Closed Nyaacinth closed 2 years ago

Nyaacinth commented 2 years ago
node_modules/vite-electron-plugin/src/config.ts:123:21 - error TS2551: Property 'electronApp' does not exist on type 'Process'. Did you mean 'electron'?

123         if (process.electronApp) {
                        ~~~~~~~~~~~

(And 4 more similar issues about process.electronApp)

Seems like missing type definition

caoxiemeihao commented 2 years ago

tsconfig.json


{
+ "exclude": ["node_modules"]
}
Nyaacinth commented 2 years ago

tsconfig.json

{
+ "exclude": ["node_modules"]
}

It has been excluded, since “vite-electron-plugin” or “vite-plugin-electron” is imported in vite.config.ts, the source files in the package is treated as explicitly included.

tsconfig.json

{
    "exclude": ["node_modules"],
    "compilerOptions": {
        "target": "ESNext",
        "useDefineForClassFields": true,
        "lib": ["DOM", "DOM.Iterable", "ESNext"],
        "allowJs": false,
        "skipLibCheck": true,
        "esModuleInterop": false,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "forceConsistentCasingInFileNames": true,
        "module": "ESNext",
        "moduleResolution": "Node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "noEmit": true,
        "jsx": "react-jsx",
        "types": ["vite/client"]
    }
}
caoxiemeihao commented 2 years ago

Consider explicitly declare them? https://github.com/electron-vite/vite-electron-plugin/blob/1cac66fa011e346c17cf9f71c65323f83790b2a2/electron-env.d.ts#L2-L12

Nyaacinth commented 2 years ago

Comparing vite-plugin-electron@0.9.3 (Passed tsc checking) and vite-electron-plugin@0.5.0 (Failed on checking), I found that types in package.json of vite-electron-plugin is set to src, That might caused tsc not checking electron-env.d.ts in the package root. So I tried to import "../electron-env" in src/index.ts of vite-electron-plugin, and that solved the issue.

But, I don't know how to solve this issue elegantly, hope this info can help you.

caoxiemeihao commented 2 years ago

Thanks for your feedback! Possibly generating additional .d.ts is better :)