0

我正在尝试在 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时,它​​并没有显示出来,我认为这是因为那个错误

4

2 回答 2

0

我的 tsconfig.json 中有以下内容,它工作正常

   {
    "compilerOptions": {
    "target": "ES5",
     "experimentalDecorators": true
      }
    }
于 2020-07-15T13:15:32.287 回答
0

伙计们,这似乎是视觉工作室代码中的一个错误

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

至少这为我解决了我不知道如何...

于 2020-07-15T13:18:12.980 回答