更新到Angular 8,现在一切都坏了

  • 本文关键字:坏了 Angular 更新 angular
  • 更新时间 :
  • 英文 :


我想将我的Angular项目从7.3.6(CLI(更新到最新版本(8.3.16(。但失败了。我照导游说的做了:https://update.angular.io/#7.2:8.0

我不得不把所有的零钱都藏起来,因为实际上所有的东西都是红色的

import { Injectable, HostListener, Directive, EventEmitter, Output, HostBinding, ElementRef, Renderer2 } from '@angular/core';

所有这些进口都是红色的。在隐藏之后,仍然什么都不会起作用,因为有些东西更新到了8.3.16,有些没有,我认为该项目停留在7.2上。

ng version给我:

Angular CLI: 8.3.16
Node: 11.12.0
OS: win32 x64
Angular: 8.2.13
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.803.16
@angular-devkit/build-angular      0.803.16
@angular-devkit/build-optimizer    0.803.16
@angular-devkit/build-webpack      0.803.16
@angular-devkit/core               8.3.16
@angular-devkit/schematics         8.3.16
@angular/cdk                       7.3.7
@angular/cli                       8.3.16
@angular/material                  7.3.7
@angular/material-moment-adapter   7.3.7
@ngtools/webpack                   8.3.16
@schematics/angular                8.3.16
@schematics/update                 0.803.16
rxjs                               6.5.3
typescript                         3.5.3
webpack                            4.39.2

错误的例子如下:

ERROR in node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
node_modules/rxjs/Rx.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat'.
src/app/app.module.ts(32,31): error TS2307: Cannot find module 'angular-emojify'.
src/app/chat/chat.component.ts(13,4): error TS2554: Expected 2 arguments, but got 1.
src/app/chat/chat.component.ts(16,4): error TS2554: Expected 2 arguments, but got 1.
src/app/chat/chat.component.ts(19,4): error TS2554: Expected 2 arguments, but got 1.
src/app/chat/chatarea/chatarea.component.ts(27,4): error TS2554: Expected 2 arguments, but got 1.
src/app/chat/chatmessage/chatmessage.component.ts(50,4): error TS2554: Expected 2 arguments, but got 1.
src/app/chat/chatroom-list/chatroom-list.component.ts(34,4): error TS2554: Expected 2 arguments, but got 1.
src/app/registration/registration.component.ts(36,4): error TS2554: Expected 2 arguments, but got 1.
src/app/services/websocket.service.ts(3,10): error TS2305: Module '"C:/Users/user/Git/chat/client/node_modules/rxjs/Observable"' has no exported member 'Observable'.
src/app/services/websocket.service.ts(25,17): error TS2694: Namespace '"C:/Users/user/Git/chat/client/node_modules/rxjs/Rx"' has no exported member 'Subject'.
src/app/services/websocket.service.ts(202,15): error TS2339: Property 'Subject' does not exist on type 'typeof import("C:/Users/user/Git/chat/client/node_modules/rxjs/Rx")'.
src/app/shared/validators/custom-validators.ts(64,29): error TS2339: Property 'timer' does not exist on type 'typeof Observable'.
src/app/shared/validators/custom-validators.ts(65,74): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.
src/app/shared/validators/custom-validators.ts(77,27): error TS2339: Property 'timer' does not exist on type 'typeof Observable'.
src/app/shared/validators/custom-validators.ts(78,72): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.
src/app/shared/validators/custom-validators.ts(96,29): error TS2339: Property 'timer' does not exist on type 'typeof Observable'.
src/app/shared/validators/custom-validators.ts(97,71): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.
src/app/shared/validators/custom-validators.ts(109,27): error TS2339: Property 'timer' does not exist on type 'typeof Observable'.
src/app/shared/validators/custom-validators.ts(110,69): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.
src/app/shared/validators/custom-validators.ts(126,27): error TS2339: Property 'timer' does not exist on type 'typeof Observable'.
src/app/shared/validators/custom-validators.ts(127,116): error TS2339: Property 'map' does not exist on type 'Observable<Object>'.

我不是一个人在做这个项目。模块angular emojify在更新时出现了问题,但我删除了它,并尝试自己创建管道。

我真的不知道该怎么办,因为项目和CLI不再匹配了。

Angular官方指南明确指出:

角度更新指南|7.2->8.0高级应用

更新前

  • 如果使用遗留的HttpModule和Http服务,请切换到
    HttpClientModule和HttpClient服务。HttpClient简化了
    默认的人机工程学(您不再需要映射到JSON(,并且
    现在支持类型化的返回值和拦截器。阅读
    angular.io上的更多信息
  • 一旦您和所有依赖项更新到
    RxJS 6,请删除RxJS-compat
  • 如果使用Angular Service工作程序,
    请将任何版本的files迁移到文件阵列中。行为与
    相同

我认为您错过了首先更新代码以使用最新的RxJS 6兼容的步骤。

最新更新