TypeScript module Augmentation

前端 未结 1 2005
借酒劲吻你
借酒劲吻你 2021-01-11 19:56

I have extension for observable. It was working perfectly fine but now I\'ve updated to angular 6 with typescript 2.7.2.

import { Observable } from \'rxjs/O         


        
相关标签:
1条回答
  • 2021-01-11 20:46

    When merging declarations, the specified module path must exactly match the path to the actual module.

    With RxJS version 6, you will need to change your module declaration, as the internal structure has changed. From memory, it should be:

    declare module 'rxjs/internal/Observable' {
        export interface Observable<T> {
            safeSubscribe<T>(this: Observable<T>, component: BaseComponent,
                next?: (value: T) => void, error?: (error: T) => void, complete?: () => void): Subscription;
        }
    }
    

    For an example, see one of the patching imports in rxjs-compat.

    0 讨论(0)
提交回复
热议问题