rxjs: Missing Definition file for UMD module

I’ve downloaded and compiled the project building for all targets, and noticed that the umd/global distribution is missing the .d.ts definition files.

I’ve played around a little, and the closest I got was to compile to amd using outFile instead of outDir, that generates a single .d.ts, but its missing the Global name “Rx”, for example, its generating

declare module "Subscription" {
    export class Subscription {
        static EMPTY: Subscription;
        isUnsubscribed: boolean;
        constructor(_unsubscribe?: () => void);
        unsubscribe(): void;
        add(subscription: Subscription | Function | void): void;
        remove(subscription: Subscription): void;
    }
    export class UnsubscriptionError extends Error {
        errors: any[];
        constructor(errors: any[]);
    }
}

Where I think it should create

declare module "Rx.Subscription" {

Sadly the project Im building now needs the umd version and I can’t get typings 😦

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 22 (12 by maintainers)

Most upvoted comments

For anyone still trying to get RxJS 5 to load with typings in an AMD / RequireJS environment, you must do the following:

  • Install (I’m using core-js for the promise shim): npm install core-js @reactivex/rxjs --save
  • Load the UMD library manually in your index.html BEFORE require.js: <script src="//unpkg.com/core-js/client/shim.js"></script> <script src="//unpkg.com/@reactivex/rxjs/dist/global/Rx.js"></script>
  • In your main app.d.ts, add type references (you may be able to skip this depending on your tsconfig.json): /// <reference path='../node_modules/@types/core-js/index.d.ts' /> /// <reference path='../node_modules/@reactivex/rxjs/dist/cjs/Rx.d.ts' />
  • In your main app.ts, redefine RxJS so RequireJS doesn’t load it again:
(<any>window).define('@reactivex/rxjs', [], function() {
  return (<any>window).Rx;
});
  • For r.js, exclude the module from require.config’s paths:
paths: {
   '@reactivex/rxjs': 'empty:'
}

Now you can import * as Rx from '@reactivex/rxjs' from any .ts file in your project.