简体   繁体   English

如何让 WebStorm 识别 Angular Material 语法?

[英]How can I make WebStorm recognize Angular Material syntax?

I'm using @angular/material with Angular 9. WebStorm doesn't recognize the @angular/material syntax:我将@angular/material与Angular 9 一起使用。WebStorm 无法识别@angular/material 语法:

在此处输入图像描述

It also doesn't recognize the correct type:它也无法识别正确的类型:

在此处输入图像描述

No custom shenanigans going on.没有自定义的恶作剧。 Everything is straight from their tutorials in a brand new angular project generated with the CLI.一切都直接来自他们在使用 CLI 生成的全新 angular 项目中的教程。

The table declaration:表声明:

<table mat-table [dataSource]="dataSource" matSort class="mat-elevation-z8">

My TS file:我的 TS 文件:

export interface Property {
  street: string;
  zip: string;
  city: string;
  lat: number;
  lng: number;
  rooms: number;
  area: number;
  monthlyFee: number;
  builtYear: number;
  soldDate: string;
}

const ELEMENT_DATA: Property[] = [
  {
    street: 'Vasagatan 1',
    zip: '11345',
    city: 'Stockholm',
    lat: 89.123912,
    lng: 89.123912,
    rooms: 3,
    area: 87,
    monthlyFee: 2450,
    builtYear: 1989,
    soldDate: '2020-04-30',
  },
];

@Component({
  selector: 'app-dataset-list',
  templateUrl: './dataset-list.component.html',
  styleUrls: ['./dataset-list.component.scss']
})
export class DatasetListComponent implements OnInit {

  displayedColumns: string[] = ['street', 'zip', 'city', 'lat', 'lng', 'rooms', 'area', 'monthlyFee', 'builtYear', 'soldDate'];
  dataSource = new MatTableDataSource(ELEMENT_DATA);

  @ViewChild(MatSort, {static: true}) sort: MatSort;

  ngOnInit() {
    this.dataSource.sort = this.sort;
  }
}

The first issue must be caused by problems recognizing the metadata added to material classes when building the project with Ivy, WEB-45270 .第一个问题一定是由于在使用 Ivy 构建项目时识别添加到材质类的元数据出现问题, WEB-45270 This issue is solved in upcoming WebStorm 2010.1.2.这个问题在即将发布的 WebStorm 2010.1.2 中得到解决。

The second looks related to WEB-43716第二个看起来与WEB-43716相关

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM