Skip to content

import member from export as namespace library does not import types #16155

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

Closed
cwmoo740 opened this issue May 30, 2017 · 1 comment
Closed

import member from export as namespace library does not import types #16155

cwmoo740 opened this issue May 30, 2017 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue

Comments

@cwmoo740
Copy link

TypeScript Version: 2.3.3

Code

import { createSelector } from 'reselect';
/*
 * changing the import to
 * import * as reselect from 'reselect';
 * and accessing reselect.createSelector fixes the issue
*/
export interface State {
    a: string;
    b: number;
}
export const selector = createSelector<State, string, number, { out: string }>(
    state => state.a,
    state => state.b,
    (a, b) => {
        return {
            out: `${a}+${b}`
        };
    }
);
console.log(selector({ a: 'string', b: 5 }));

outputs this index.d.ts:

export interface State {
    a: string;
    b: number;
}
export declare const selector: Reselect.OutputSelector<State, {
    out: string;
}, (res1: string, res2: number) => {
    out: string;
}>;

Expected behavior:
The output .d.ts file will include an import for the relevant type from 'reselect'.

Actual behavior:
The output .d.ts file attempts to access Reselect as a global namespace. Any downstream consumer that imports from this code will error.

A full example can be found here:

https://github.com/cwmoo740/typescript-export-as-bug

@cwmoo740 cwmoo740 changed the title import member from export as namespace library import member from export as namespace library does not import types May 30, 2017
@cwmoo740
Copy link
Author

The typing file for reselect may also be helpful:

https://github.com/reactjs/reselect/blob/master/src/index.d.ts

@mhegazy mhegazy added Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files labels Aug 24, 2017
@mhegazy mhegazy modified the milestone: TypeScript 2.6 Sep 1, 2017
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Sep 7, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Domain: Declaration Emit The issue relates to the emission of d.ts files Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

3 participants