stasberkov / espruino-ts-quickstart

Quickstart for Espruino using typescript and Visual Studio Code IDE
25 stars 18 forks source link

Doesn't build in VS Code #8

Open ktrzeciaknubisa opened 2 months ago

ktrzeciaknubisa commented 2 months ago

I was hoping for this project, but unfortunately it does not build in VS Code atm.

[15:42:10] Using gulpfile C:\Prv\Visual Studio Code\EspruinoQuickStart\espruino-ts-quickstart-master\gulpfile.js
[15:42:10] Starting 'build'...
[15:42:10] Starting 'prepare-for-espruino'...
[15:42:10] Starting 'compile-ts'...
[15:42:10] Starting 'gen-config-ts'...
[15:42:10] Finished 'gen-config-ts' after 2.7 ms
[15:42:10] Starting 'compile_ts'...
C:/Prv/Visual Studio Code/EspruinoQuickStart/espruino-ts-quickstart-master/node_modules/@types/espruino/index.d.ts(438,13): error TS2300: Duplicate identifier 'USB'.
C:/Prv/Visual Studio Code/EspruinoQuickStart/espruino-ts-quickstart-master/node_modules/@types/w3c-web-usb/index.d.ts(104,15): error TS2300: Duplicate identifier 'USB'.
C:/Prv/Visual Studio Code/EspruinoQuickStart/espruino-ts-quickstart-master/node_modules/@types/w3c-web-usb/index.d.ts(171,19): error TS2749: 'USB' refers to a value, but is being used as a type here. Did you mean 'typeof USB'?
TypeScript: 3 semantic errors

Duplicate identifier 'USB'.

Indeed USB is defined in both:

@types/espruino/index.d.ts @types/w3c-web-usb/index.d.ts

ktrzeciaknubisa commented 2 months ago

Ok, i renamed USB -> USB1 in @types/w3c-web-usb/index.d.ts (two occurrences in a file) and it builds now. This is just a name of a class so it should be fine to go this way.

jgumoes commented 2 weeks ago

Adding the following to tsconfig.js should stop the problem, and you won't have to mess with node_modules if you need to reinstall:

{
  "compilerOptions": {
    ...
    "types": [
      "espruino",
      "json5"
    ],
    ...
  },
}

Explicitly listing types will omit any that aren't listed, so listing everything but "w3c-web-usb" will stop it from being used. https://www.typescriptlang.org/tsconfig/#types