Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export = in declarations file #73

Closed
fdecampredon opened this issue Nov 20, 2014 · 5 comments
Closed

export = in declarations file #73

fdecampredon opened this issue Nov 20, 2014 · 5 comments
Assignees

Comments

@fdecampredon
Copy link

@fdecampredon fdecampredon commented Nov 20, 2014

I try to use bluebird.
The definition file is like that.

declare module "bluebird" {

  declare class Promise<R>  {
    constructor(callback: (resolve : (result: R) => void, reject: (error: any) => void) => void): void;
    then<U>(onFulfill?: (value: R) => Promise<U> | U, onReject?: (error: any) => Promise<U> | U): Promise<U>;
    catch<U>(onRejected?: (error: any) => Promise<U> | U ): Promise<U>;
    static resolve<T>(thenable?: Promise<T> | T): Promise<T>;
    static reject(error: any): Promise<any>;
    static all<T>(promises: Array<Promise<T>>): Promise<Array<T>>;
    static race<T>(promises: Array<Promise<T>>): Promise<T>;
  }
}

The problem is that I have no way to declare that 'bluebird' is 'Promise', with typescript I would do :

export = Promise;

is there a way to declare such behavior ?

@avikchaudhuri
Copy link
Contributor

@avikchaudhuri avikchaudhuri commented Nov 20, 2014

Not yet, will fix.

@ptmt
Copy link
Contributor

@ptmt ptmt commented Nov 26, 2014

+1.

Would be nice to be able to export not only class, but function and var too:

declare module 'some-module' {
   declare var typeOfModule : string;
}
@ransanjeev
Copy link

@ransanjeev ransanjeev commented May 10, 2015

What's the workaround for this?
I am trying to use the var ClassNames = require('classnames') ;
Not sure how to declar the interface for this.

@samwgoldman
Copy link
Member

@samwgoldman samwgoldman commented May 20, 2015

Generally you should be able to use the "special" identifier exports to declare your default exports. However, it seems there is an issue (#457) with polymorphic default exports which will prevent a default exported bluebird Promise class from correctly type checking.

See #455 for an example of the exports declaration.

@mroch
Copy link
Contributor

@mroch mroch commented Jun 18, 2015

ok, #457 is fixed, so this should be possible in master, and when 0.13 is released.

@mroch mroch closed this Jun 18, 2015
jeffmo pushed a commit to jeffmo/flow that referenced this issue Jul 31, 2015
Support declare var, declare function, declare class and declare module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants