【发布时间】:2021-01-12 01:01:59
【问题描述】:
是否可以设置 Intellij 在 Angular 模板中显示 TypeScript 错误?我在stackblitz 上共享了以下虚拟应用程序。如果我创建一个带有可选对象参数的@Input 并在模板中使用它,我会在控制台中遇到错误,但 Intellij 可以。没有任何错误。注意,我有严格模式:
tsconfig.json
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
}
data.ts
export interface Data {
id?: number;
title?: string;
}
data.component.ts
@Component({
selector: 'app-data',
templateUrl: './data.component.html',
})
export class DataComponent {
@Input()
public data?: Data;
}
data.component.html
<p>{{data.title}}</p>
终端输出
模板在 Intellij 中打开
【问题讨论】: