当创建新模块时,抛出对decorators的实验支持错误



我正在尝试用在angular项目中生成新模块

ng g module core/employee-applicant --routing=true

并且生成的新模块抛出异常

对decorator的实验性支持是一个受未来版本中的更改。在中设置"experialDecorators"选项您的"tsconfig"或"jsconfig"以删除此警告

,而在其他模块中,它不会生成该错误。

出现错误的新模块

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { EmployeeApplicantRoutingModule } from './employee-applicant-routing.module';

@NgModule({
declarations: [],
imports: [
CommonModule,
EmployeeApplicantRoutingModule
]
})
export class --> EmployeeApplicantModule (the error on visual studio code red under line){ }

没有弹出该错误的旧模块

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { AuthRoutingModule } from './auth-routing.module';
import { LoginComponent } from './login/login.component';
import { MaterialModule } from 'src/app/shared/modules/material.module';
import { PipesModule } from 'src/app/pipes-module';

@NgModule({
declarations: [
LoginComponent
],
imports: [
CommonModule,
AuthRoutingModule,
FormsModule,
ReactiveFormsModule,
MaterialModule,
PipesModule,
]
})
export class AuthModule { }

与使用该新模块生成的路由模块也是一样的。

对于experimentalDecorators,我在我的项目中的每个tsconfig文件中都添加了它

tsconfig.app.json

tsconfig.spec.json

tsconfig.json

tsconfig.base.json

如果有人能告诉我这些文件之间有什么区别

还有一件事,当我试图将它导入app.module时,它没有显示,我认为这是因为错误

伙计们,这似乎是visual studio代码中的一个错误

我通过写入整个路径将其硬导入其他模块,然后错误消失

至少这能帮我解决问题我不知道怎么。。。

我的tsconfig.json中有以下内容,它可以很好地进行

{
"compilerOptions": {
"target": "ES5",
"experimentalDecorators": true
}
}

最新更新