Skip to content

Module/class augmentation doesn't work #11406

Closed
@MoonStorm

Description

@MoonStorm

TypeScript Version: 2.0.3

Code

// A *self-contained* demonstration of the problem follows...
// rxjs installed via npm
// seems to expose everything via its .d.ts file:
export { Observable } from './Observable';

// attempting to augment the Observable class exposed by the rxjs module
// observable.operators.ts
import {Observable} from 'rxjs'

declare module 'rxjs' {
    interface Observable<T> {
        doStuff():void;
    }
}

// consumer.ts
import { Observable, Subscription } from 'rxjs'
export class Consumer{
  private _sub:Subscription;
   constructor(){
      this._sub = Observable.from([1,2,3]).subscribe();
   }
}

Expected behavior:
The doStuff to appear available in the rxjs module on the Observable class.

Actual behavior:
Attempting to use import {Observable} from 'rxjs' in another file (consumer.ts) causes compilation errors.

Export declaration conflicts with exported declaration of 'Observable'
Property 'subscribe' does not exist on type 'Observable'
etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions