Angular 2 RC4最新-扩展时“未捕获的TypeError:无法读取未定义的属性'prototype'”

cbierman

我有一个较旧的Angular 2 RC4项目,我已经更新到了最新版本(现在是2.0.0)。ng build使用最新版本的angular CLI(1.0.0-beta.14)运行时,没有出现任何编译错误,但是在运行ng serve时,标题中出现了错误。

有问题的基本服务如下:

import { Injectable } from '@angular/core';
import { Response } from "@angular/http";
import { Observable } from "rxjs/Observable";


export class PkServiceBaseService {
  // Implementation
}

当扩展基本服务的类看起来像:

import { Injectable } from '@angular/core';
import { Http, Response, Headers } from '@angular/http';
import { Observable } from "rxjs/Observable";


import { PkServiceBaseService } from "./";
import { JwtAuthorizationService } from "./";
import { Task } from "../shared";

@Injectable()
export class TaskService extends PkServiceBaseService {
  // Implementation
}

这两个文件位于同一目录中,并通过该index.ts文件导出

奇怪的是,在使用继承时,我在某些模型类中遇到了同样的错误,但是现在已经消失了。

另外,错误的堆栈跟踪包含对另一个服务的引用,该服务UserService也已扩展PkServiceBaseService,但在中完全没有使用TaskService

请让我知道是否可以提供更多信息。我已经省略了实现细节,因为问题似乎仅与继承有关,但是我当然可以提供更多信息。

完整的堆栈跟踪,以供参考:

__extends              @   task.service.ts:40
(anonymous function)   @   user.service.ts:11
(anonymous function)   @   user.service.ts:105
__webpack_require__    @   bootstrap 32723c5…:52
(anonymous function)   @   main.bundle.js:4803
__webpack_require__    @   bootstrap 32723c5…:52
(anonymous function)   @   prep-kids.component.ts:18
__webpack_require__    @   bootstrap 32723c5…:52
(anonymous function)   @   icon-registry.js:375
__webpack_require__    @   bootstrap 32723c5…:52
(anonymous function)   @   src async:7
__webpack_require__    @   bootstrap 32723c5…:52
(anonymous function)   @   main.bundle.js:81928
__webpack_require__    @   bootstrap 32723c5…:52
webpackJsonpCallback   @   bootstrap 32723c5…:23
(anonymous function)   @   main.bundle.js:1

编辑:我应该补充一点,我已经遵循Angular 2的RC4到RC5迁移步骤,以及Angular CLI从Beta.10升级到Beta.14的步骤

cbierman

经过大量的摸索和摸索,我终于能够使我的应用程序再次运行。

Angular CLI队列中的此问题使我步入正轨。似乎有时在index.ts文件中使用通配符会导致在编译后找到该类时出现问题。

例如,在我做类似的事情之前:

export * from "./user.service";
export * from "./pk-base-service.service";

但是将我的东西更改index.ts为:

export {UserService} from "./user.service";
export {PkBaseService} from "./pk-base-service.service";

摆脱了我的问题。

在某些情况下,我也会从模型类中得到同样的错误。以前,当我必须在同一文件夹中进行建模时,我可以执行以下操作:

import { User } from "./";

将导入更改为:

import { User } from "./user.model";

摆脱了错误。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Angular 2-未捕获(承诺):TypeError:无法读取未定义的属性“ title”

Angular 2 RC4:无法从表单获取值

Angular 2 rc1 TypeError:无法读取未定义的属性“注释”

Google Picker API + Angular2收到未捕获的TypeError:无法读取未定义的属性'handleAuthResult'

Angular4 ng2-charts TypeError:无法读取未定义的属性“长度”

Ionic 3和Angular 4-未捕获(承诺):TypeError:无法读取未定义的属性“ title”

Angular2(RC-4):无法读取未定义的属性“ pathsWithParams”

Angular 2 TypeError:无法读取未定义的属性“ toUpperCase”

如何恢复html(未生成的代码)angular2 RC4的源代码

angular 2 rc-无法读取未定义的属性“ request”

未捕获的TypeError:无法读取未定义的属性“ prototype”(inherits_browser.js)

未捕获的TypeError:无法读取未定义的sails.io.js的属性“ prototype”

IONIC 4 + Angular7:错误错误:未捕获(承诺):类型错误:无法读取未定义的属性“then”

Angular2 / 4-无法读取未定义的属性订阅

Angular Carousels:未捕获的TypeError:在与Angular JS一起使用轮播时,无法读取未定义的属性“ offsetWidth”

Angular 2自定义装饰器(适用于RC4之后的版本)提供了“多个组件”

使用Angular2中的动态组件时出现错误“错误TypeError:无法读取未定义的属性'createComponent'”

TypeError:在angular2中执行单元测试时,无法读取未定义故障的属性“快照”

ReferenceError:nv 未在 angular 2.00 rc4 中定义

NgZone / Angular2 / Ionic2 TypeError:无法读取未定义的属性“运行”

@ angular / cli @ 1.7.4-未捕获的TypeError:无法读取未定义的属性“模块”

Angular 7-错误错误:未捕获(承诺):TypeError:无法读取未定义的属性“ forEach”

Angular 7 + Ionic 4 构建失败“TypeError:无法读取未定义的属性(读取'种类')”

angular2:错误:TypeError:无法读取未定义的属性“ ...”

Angular 2异常:TypeError:无法读取未定义的属性“ annotations”

TypeError:无法读取angular2中未定义的属性“ 0”以在datepicker中使用索引

Webpacked Angular2应用程序TypeError:无法读取未定义的属性“ getOptional”

Angular 2-TypeError:无法读取未定义的属性“ apply”

Angular2:TypeError:无法读取未定义的属性“ Symbol(Symbol.iterator)”