【发布时间】:2020-11-04 23:33:20
【问题描述】:
我正在尝试在 Angular 项目中生成新模块
ng g module core/employee-applicant --routing=true
并且生成的新模块抛出异常
对装饰器的实验性支持是一项受制于 在将来的版本中更改。设置 'experimentalDecorators' 选项 你的 '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 时,它并没有显示出来,我认为这是因为那个错误
【问题讨论】:
标签: angular typescript angular10