Type checking in Angular 2 templates

后端 未结 7 534
夕颜
夕颜 2021-02-02 06:07

We are building an application in Angular 2 and TypeScript. We try to statically check types where it is possible. Is there any way to check types in templates? Consider the fol

7条回答
  •  难免孤独
    2021-02-02 06:21

    WebStorm from Jetbrains can do that.

    My original answer:

    I don't think there's a reliable way to do that without doing some think like React does with the JSX or TSX extension to the language.

    The typescript compiler doesn't know about your HTML files, and will just ignore them. Also, there's no strong coupling between your templates and the Controller code... there's nothing preventing you from reusing the same template across several controllers.

提交回复
热议问题