electron-userland / electron-webpack

Scripts and configurations to compile Electron applications using webpack
https://webpack.electron.build/
903 stars 170 forks source link

Typescript causes compilation to fail #289

Open NileDaley opened 5 years ago

NileDaley commented 5 years ago

I have a typescript react app that uses electron-webpack. My tsconfig.json looks like this:

{
    "extends": "./node_modules/electron-webpack/tsconfig-base.json",
    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true,
        "jsx": "react",
        "baseUrl": ".",
        "paths": {
            "@/*": ["src/renderer/*"],
            "@public/*": ["public/*"]
        },
        "module": "es2015",
        "moduleResolution": "node",
        "noImplicitAny": true,
        "noImplicitThis": true,
        "skipLibCheck": true,
        "strictNullChecks": true,
        "sourceMap": true,
        "target": "esnext"
    },
    "include": ["./src"],
    "exclude": ["node_modules"]
}

When running electron-webpack --dev, the application compiles just fine - even with typescript warnings. However, as soon as I run electron-webpack, the build will fail as soon as there are any typescript warnings.

Does electron-webpack not use the tsconfig.json file, or is it just more strict in production? It seems like the issue is with TSLint, which I don't use in my project - so is this something that is run during the compile step?

Its just super annoying that I can't even compile for little things such as unused variables, etc. Is there a way I can get around this, or a config file that I can change?

Nifled commented 5 years ago

That's kinda the intention of using TypeScript. Regardless, you can change rules like the unused variables one directly your compilerOptions in tsconfig.json. Here are all the rules and the dfiferent values you can assign them.

In the case of the unused variables warning/error, there's a rule named noUnusedLocals, which you can set to false to stop the errors (at least for that specific compilation error).