alangpierce/sucrase

TypeScript type-only re-exports not always properly elided

alangpierce opened this issue · 0 comments

Playground link

Example code with different re-export cases:

export {A} from 'module1';
export type {B} from 'module2';
export {type C} from 'module3';
export {} from 'module4';
export {D, type E} from 'module5';

With the TypeScript transform enabled, the expected behavior is to fully elide modules 2, 3, and 4, so that they aren't imported, but Sucrase currently only elides module 2. (Babel keeps module 4 but tsc elides it, and I'm considering TypeScript's implementation to be the authoritative one.)

With the Flow transform enabled, only modules 1, 2, and 4 are valid syntax, and Sucrase correctly only elides module 2. With no type transforms enabled, only modules 1 and 4 are valid syntax, and Sucrase correctly doesn't elide either of them.