angular – TypeScript模块扩充
发布时间:2020-12-17 17:24:12 所属栏目:安全 来源:网络整理
导读:我有可观察的扩展.它工作得很好,但现在我已经更新到角度为6的打字稿2.7.2. import { Observable } from 'rxjs/Observable';import { BaseComponent } from './base-component';import { Subscription } from 'rxjs/Subscription';import { Subscribable } fr
我有可观察的扩展.它工作得很好,但现在我已经更新到角度为6的打字稿2.7.2.
import { Observable } from 'rxjs/Observable'; import { BaseComponent } from './base-component'; import { Subscription } from 'rxjs/Subscription'; import { Subscribable } from 'rxjs'; declare module 'rxjs/Observable' { export interface Observable<T> { safeSubscribe<T>(this: Observable<T>,component: BaseComponent,next?: (value: T) => void,error?: (error: T) => void,complete?: () => void): Subscription; } } export function safeSubscribe<T>(this: Observable<T>,complete?: () => void): Subscription { let sub = this.subscribe(next,error,complete); component.markForSafeDelete(sub); return sub; } Observable.prototype.safeSubscribe = safeSubscribe; 这段代码不起作用 >’Observable’仅指类型,但在此处用作值. https://www.typescriptlang.org/docs/handbook/declaration-merging.html 解决方法
合并声明时,指定的模块路径必须与实际模块的路径完全匹配.
使用RxJS版本6,您将需要更改模块声明,因为内部结构已更改.从记忆中,它应该是: declare module 'rxjs/internal/Observable' { export interface Observable<T> { safeSubscribe<T>(this: Observable<T>,complete?: () => void): Subscription; } } 有关示例,请参阅rxjs-compat中的one of the patching imports. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- .net webservice 因 URL 意外地以“/GetAllArticle”结束,
- BootStrap入门学习第一篇
- angular2 / 4.当FormsModule内置时,我应该使用Reactive For
- AngularJS(四)——ng-controller(控制器)
- angularjs – 有没有办法在AngularUI路由器中的任何子解析之
- 使用soapUI进行webservices性能测试
- 【webservice】基于axis2设计带soaphead安全机制的webservi
- go语言运行shell命令
- AngularJs $scope.$apply
- Docker hello-world:验证错误
推荐文章
站长推荐
- WebService大讲堂之Axis2(4):二进制文件传输
- webservice用soapUI测试日期格式输入
- Webpack3.x 通过Webpack加载Bootstrap的CSS/Scss
- webservice快速入门-使用JAX-WS注解的方式快速搭
- 从scala.concurrent.Future抛出异常
- 如何加快docker中sbt scala的构建速度?
- 如何关闭Scala Fast Compilation服务器(FSC)超时
- 如何在scala.js中使用scala.sys.process
- 官方Angular 2 http教程中的私有变量命名约定
- Ionic / AngularJS:如何从表单本地保存数据?
热点阅读