score:0

turn off typescript language service in settings > language & frameworks > typescript . then turn it back on. this solved it for me.

score:3

unchecking recompile on changes in settings > language & frameworks > typescript > typescript language service solved the issue, albeit the underlying cause remains unknown.

score:3

when i had this problem in webstorm 2019.3.1 i was able to resolve it by going to file > invalidate caches / restart... and pressing the "invalidate and restart" button. when webstorm restarted the error was gone.

score:50

update 11/05/2020:

closing and reopening the file fixes it as well. it seems intellij typescript parsing can get out of sync.

original answer

i might be a little late to the party, but i also experienced this and what fixed it for me were the following steps.

  1. create a new file.
  2. copy the contents of the old file to the new file.
  3. delete the old file.
  4. rename the new file to match the old file's name.

now i'm not exactly sure why that fixes the issue, but i have a few guesses. i'm using intellij, which is i assume what you're using too since i've never had this issue elsewhere, and ts compiles just fine even with the issue present. it's more of an in-editor-error kind of deal (for me at least). reopening the editor may fix this as well.

hope this all helps!

guess 1

something to do with line endings. git changes your line endings when you do common git operations based on your os, since windows & linux have different line-ending sequences. that may be something tripping intellij up. i once hit this issue after pulling from `master` on a project, so that gives me this impression.


guess 2

you have an "invisible" inserted unicode character somewhere in your code. this happened to me a few times, due to a custom macos keyboard layout. both of my hunches hover around things to do with "invisible" characters, but i'm afraid this is where my expertise ends. maybe someone with some more know-how can chime in down the line.

Related Query

More Query from same tag