0

I decided to start using TypeScript, and so I set up a simple project. However, I seem to get some annoying linting errors which I do not know how to solve.

  • Imports get the Cannot find module 'X'. ts(2307) error
  • On my linux machine Promises and Errors get the Cannot find name 'X' error
  • On my linux machine console.log/error statements get a similar error and it recommends me to add "dom" to the lib in tsconfig.json, which doesn't help.

You can see the repo here (https://github.com/feareoc/chat). I'd appreciate any help for solve this problem!

rosengrenen
  • 731
  • 6
  • 21
  • default TS setup has no standard lib info included. you need to tell the TS engine about your environment, in your case it's the browser. Generate a `tsconfig.json` then config it. All important things are noted in comments in that file. – hackape May 05 '19 at 03:57
  • check this [post](https://stackoverflow.com/questions/36916989/how-can-i-generate-tsconfig-json-file) to see how to generate a `tsconfig.json`. [This link](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) and [this one](https://www.typescriptlang.org/docs/handbook/compiler-options.html) are the docs. Look for `--lib` in last link. – hackape May 05 '19 at 04:00
  • Thanks for your input. Your comments made me realise I have dockerized my node app, which means installing all modules (including typescript) only in the container. Unless I install the modules outside the container I still, obviously, get the `Cannot find module 'X'` error. Is there a way such that I don't have to install the modules outside the container for TS development, or do I have to stick with that for now? – rosengrenen May 05 '19 at 10:48
  • 1
    check out [vscode remote](https://code.visualstudio.com/docs/remote/remote-overview). I haven't tested this feature, but it sounds like what you need – hackape May 05 '19 at 10:51
  • Thanks, that seems to work very well, only thing I cannot get working is getting the list of extensions till install in the container (I'm connecting to my docker-compose service), but that's for another thread – rosengrenen May 05 '19 at 12:55

0 Answers0