首页 > 解决方案 > 在 Intellij/Webstorm 中的 html 中显示打字稿错误

问题描述

是否可以设置 Intellij 在 Angular 模板中显示 TypeScript 错误?我在stackblitz上共享了以下虚拟应用程序。如果我@Input使用可选对象参数创建一个并在模板中使用它,我会在控制台中遇到错误,但 Intellij 可以。没有任何错误。注意,我有严格模式:

tsconfig.json

"angularCompilerOptions": {
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
}

数据.ts

export interface Data {
  id?: number;
  title?: string;
}

数据组件.ts

@Component({
  selector: 'app-data',
  templateUrl: './data.component.html',
})
export class DataComponent {
  @Input()
  public data?: Data;
}

data.component.html

<p>{{data.title}}</p>

终端输出

在此处输入图像描述

在 Intellij 中打开的模板

在此处输入图像描述

标签: typescriptintellij-idea

解决方案


目前无法做到这一点,请投票支持WEB-49062以获取有关此功能的任何进展的通知


推荐阅读