WebStorm HTML files are showing TypeScript errors for HTML elements

雨燕双飞 提交于 2019-12-11 05:45:12

问题


I installed a fresh copy of WebStorm and opened up an existing Angular project.

When I open up any HTML file in the project the IDE shows 'Cannot find div' for all div tags in the .html file. For a few seconds the IDE is fine, then it shows a '2.5.3 Typescript' tab with a list of TypeScript errors.

Some Typescript tab errors:
Error:(1, 2) TS2304: Cannot find name 'div'.
Error:(3, 4) TS2304: Cannot find name 'div'.
Error:(3, 9) TS2304: Cannot find name 'ngIf'.

I've tried invalidating the cache and restarting. I've tried disabling TSLint. I've tried injecting language for some of the attributes/tags.

Even index.html throws a bunch of TypeScript errors.

  <!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title></title>
      <base href="/">

      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="icon" type="image/x-icon" href="">
    </head>
    <body>
    </body>
    </html>

I expect no red squiggly marks in the .html file since it is all valid. It works fine in VS Code.


回答1:


Known issue, WEB-36373 is fixed in 2018.3.3.

For now, I can suggest turning Angular language service off in Settings | Languages & Frameworks | TypeScript (all the angular functionality will still be available)



来源:https://stackoverflow.com/questions/53966086/webstorm-html-files-are-showing-typescript-errors-for-html-elements

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!