为什么build --aot在environment.ts中显示错误,但是当我运行ng服务时该应用程序有效?

时间:2019-05-03 14:53:49

标签: angular5 typescript2.4

这就是问题所在。我有一个environment.ts文件,其中包含用于各种服务器的正常URL ...

我跑步时

node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --prod --aot

这些是我看到的问题:

中的错误
src/app/core/applications/screening/my-analysis.service.ts(24,35): error TS2339: Property 'dbCheckServiceURL' does not exist on type '{ production: boolean; resource: string; socket _resource: string; globalSearchUrl: string; provid...'.

src/app/core/applications/screening/my-analysis.service.ts(25,48): error TS2339: Property 'db CheckServiceURL' does not exist on type '{ production: boolean; resource: string; socket_resource : string; globalSearchUrl: string; provid...'.

例如MyAnalysisService中的代码...为了简洁起见,它已缩短

...
import { environment } from '../../../../environments/environment';
...
@Injectable()
export class MyAnalysisService {
  urlocation: string;
  screeningPersonCheckUrl: string;

  constructor(private http: HttpClient) {
    this.urlocation = environment.dbCheckServiceURL;
    this.screeningPersonCheckUrl = environment.dbCheckServiceURL+'screening/personcheck/';
  }

这是enivronment.ts文件的删节版...再次为简明起见而缩短:

export const environment = {
    production: false,
    resource: 'someURL',
    socket_resource: 'someURL',
    globalSearchUrl: 'someURL',
    provider360Url: 'someURL',
    resourcePrizm: 'someURL',
    resourcePortal: 'someURL',
    resourceDMS: 'someURL',
    resourceCSR: 'someURL',
    socketEnabled: true,
    totalAssigned: 12,
    resourceSSO: 'someURL',
    state: 'somestate',
    portalServiceURL: 'someURL',
    dbCheckServiceURL: 'someURL' **<== THIS IS FAILING ONLY on build --aot**
};

那为什么会这样呢?

我正在使用Angular 5.2.11,打字稿2.4.2

这是版本信息:

  Angular CLI: 1.7.4
  Node: 8.11.1
  OS: win32 x64
  Angular: 5.2.11
  ... animations, common, compiler, compiler-cli, core, forms
  ... http, platform-browser, platform-browser-dynamic
  ... platform-server, router

  @angular/cdk: 5.2.4
  @angular/cli: 1.7.4
  @angular/language-service: 4.4.7
  @angular/material: 7.3.7
  @angular-devkit/build-optimizer: 0.3.2
  @angular-devkit/core: 0.3.2
  @angular-devkit/schematics: 0.3.2
  @ngtools/json-schema: 1.2.0
  @ngtools/webpack: 1.10.2
  @schematics/angular: 0.3.2
  @schematics/package-update: 0.3.2
  typescript: 2.4.2
  webpack: 3.11.0

0 个答案:

没有答案