Closed
Description
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