0
我想擴展rxjs Observable
。 我從以下和https://www.typescriptlang.org/docs/handbook/declaration-merging.html說明https://github.com/Microsoft/TypeScript/issues/2821擴展打字稿模塊
我有2個文件:
rx.ts
:
/// <reference path="./rx.d.ts" />
import { Observable } from 'rxjs/Rx';
Observable.prototype.trace = function() {
return this.do(x => console.log(x))
}
rx.d.ts
:
import 'rxjs/Rx'
export { Observable } from 'rxjs/Rx';
declare module "rxjs/Rx" {
interface Observable<T> {
trace(): Observable<T>;
traceMessage(message: string): Observable<T>;
}
}
rx.ts
編譯失敗消息Cannot find name 'Observable'.
我在做什麼錯?