3
votes

I'm still learning to use typescript with react. Due to how slow react-scripts-ts was, I was turned off from it. I've tried the new typescript setup with babel 7 (react-webpack-typescript-babel) and its exceedingly fast. However there are some basic errors that I can't resolve.

Even though the project runs, in vscode I get the following errors:

  • [ts] Module ...@types/react... has no exported member 'Component'
  • [ts] Property 'setState' does not exist on type 'Counter'
  • [ts] Module ...@types/react... has no exported member 'SFC'
  • [ts] Unknown compiler option 'esModuleInterop'
  • and more...

I'm assuming this is a @types/react and typescript issue.

  1. Is @types/react not being updated?
  2. How I can get the other properties to show up?
  3. I also don't understand when to download from @types vs use the @types found in some packages other than reading the package description.
1
Unknown compiler option 'esModuleInterop' it seems you're using an older version of typescript. That's an option from typescript >=2.7 - lleon
Well react-webpack-typescript-babel is using v3.1.6 so your local typescript might not be the issue. Maybe you have an older version of typescript globally installed? - lleon
@lleon Wow. I thought I removed all globals but I was wrong. - SILENT

1 Answers

2
votes

Based on @lleon input, an old typescript version was the cause of my headache. I removed it npm un -g typescript, added vscode user setting "typescript.tsdk": "node_modules\\typescript\\lib" and restarted vscode. Works well so far.