angular - 创建新模块时抛出对装饰器的实验性支持错误
问题描述
我正在尝试在 Angular 项目中生成新模块
ng g module core/employee-applicant --routing=true
并且生成的新模块引发异常
对装饰器的实验性支持是一项可能在未来版本中更改的功能。在“tsconfig”或“jsconfig”中设置“experimentalDecorators”选项以删除此警告。
并且在其他模块中它不会生成该错误。
有错误的新模块
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时,它并没有显示出来,我认为这是因为那个错误
解决方案
我的 tsconfig.json 中有以下内容,它工作正常
{
"compilerOptions": {
"target": "ES5",
"experimentalDecorators": true
}
}
推荐阅读
- google-apps-script - Google App-Script save global Spreadsheet scirpt
- javascript - 在数组字符串中查找一个单词并为其添加粗体Javascript
- javascript - 如何解析来自 js 对象的数据
- flutter - Basic question : Alt + Enter shortcut not working for me
- node.js - Detecting binary-based file formats, not text-based formats like .txt
- mongodb - 在猫鼬中存储“可排序友好”嵌套数据的最佳方式?
- python - 在带有子图的matplotlib中向散点图添加线
- arrays - ValueError:无法将大小为 30720000 的数组重塑为形状 (10000,32,32,1)
- php - PHP 表单未提交
- ruby-on-rails - 为什么我无法解决错误“WelcomeController # index is missing a template for this request format and variant。'?