You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
importHelpers does not emit import unless at least one other import is present #12167
Noticed on a webpack project with typescript@2.1.1, using either commonjs or es2015 modules:
// index.tsimport'./empty'asyncfunctionx(){}
// empty.ts
This emits an import for tslib following by the import for empty. However, commenting the import 'empty' line out also omits the import for tslib, and the emitted code attempts to use a global __awaiter.
I thought this might have been fixed by #12151, but it's still present in current master (built with gulp LKG).
changed the title [-]importHelpers does not emit import if not at least one other import is present[/-][+]importHelpers does not emit import unless at least one other import is present[/+]on Nov 11, 2016
Activity
[-]importHelpers does not emit import if not at least one other import is present[/-][+]importHelpers does not emit import unless at least one other import is present[/+]Jessidhia commentedon Nov 11, 2016
Using
isolatedModulesgives a clue: the "Cannot compile namespaces" error hints that tsc doesn't/can't treat files withoutimport/exportas a module.With
isolatedModulesenabled, putting anexport {}is enough to pass theisolatedModulescondition, and the code is emitted with thetslibimport.Checksum commentedon Jan 10, 2017
Just wasted two hours on this! With an empty import statement, it works as intended. Tested on version
2.2.0-dev.20170110mhegazy commentedon Jan 21, 2017
If the file does not have a toplevel import/export is it is not considered a module, and it is treated as script/global.
use
--isolatedModulesto flag these files as errors.