TypeStrong / dts-bundle

Export TypeScript .d.ts files as an external module definition
MIT License
308 stars 57 forks source link

Correctly process ES6 inline/side-effect imports #79

Open arshaw opened 5 years ago

arshaw commented 5 years ago

My typescript project sometimes outputs lines like these in the generated .d.ts files:

declare const _default: import("../plugin-system").PluginDef;
export default _default;

It's essentially an inline ES6 import statement and it's valid code within a typescript definition file. I was having trouble pinpointing the exact conditions necessary to make this happen, but it happens nonetheless.

dts-bundle does not know how to process these and it outputs the line as-is, causing an unresolved module error. This PR fixes it.

Edit

The following type of imports were also not working ("side-effect-only" imports):

import "./myfile";

I've included a fix for that as well.