So I am trying to create an Electron version of my angular web app to run on desktops with a native look and feel.
I have the following script in package.json
{
"name": "app",
"version": "1.0.0",
"main": "main.js",
"license": "MIT",
"productName":"example",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build-prod": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"electron-tsc": "tsc main.ts && ng build --base-href ./ && electron .",
},
The main.ts file is basically the example given here. https://electronjs.org/docs/tutorial/first-app
Problem is that when I run the command 'npm run electron-tsc' typescript is scanning the subfolders of my directory and trying to compile my whole angular app also with lots of errors.
Like this.
node_modules/@types/selenium-webdriver/http.d.ts:24:14 - error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the
libcompiler option to es2015 or later.24 headers: Map; ~~~
node_modules/@types/selenium-webdriver/http.d.ts:48:14 - error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the
libcompiler option to es2015 or later.48 headers: Map; ~~~
node_modules/@types/selenium-webdriver/remote.d.ts:139:29 - error TS2583: Cannot find name 'Map'. Do you need to change your target library? Try changing the
libcompiler option to es2015 or later.139 setEnvironment(env: Map | {[name: string]: string} | null): this;
My main.ts has no imports and the command specifies to just compile main.ts
As it happens I do still get a valid main.js file generated and I can just run ng build --base-href ./ && electron . manually afterwards and everything works fine, it's just frustrating I can't get it to build and run with one command, and I don't understand the errors.
Here's my tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
"types": []to yourtsconfig.json. - Aaron Beall--skipLibCheckoption. That will skip type-checking in*.d.tsfiles. - Aaron BeallMapbut your lib is set toes2017which should definitely have types forMap... is it possible that yourtsconfig.jsonnot getting picked up? If you useMapinmain.tsdoes it compile? - Aaron Beall