Closed
Description
Feedback from #7125 is that some people actually do mix and match global and imported UMD libraries, which we didn't consider to be a likely scenario when implementing the feature.
Three plausible options:
- Do what we do today - bad because there's no good workaround
- Allow some syntax or configuration to say "this UMD global is actually available globally" - somewhat complex, but doable
- Allow access to all UMD globals regardless of context - misses errors where people forget to import the UMD global in a file. These are presumably somewhat rare, but it would be dumb to miss them
Sounds like it would work but probably wouldn't:
- Flag imported UMD modules as "not available for global" - bad because UMD modules will be imported in declaration files during module augmentation. It'd be weird to have differing behavior of imports from implementation files vs declaration files.
I'm inclined toward option 3 for simplicity's sake, but could see option 2 if there's some reasonably good syntax or configuration we could use in a logical place. Detecting the use of a UMD global in a TSLint rule would be straightforward if someone wanted to do this.
One path forward would be to implement option 3 and if it turns out people make the "forgot to import" error often, add a tsconfig option globals: []
that explicitly specifies which UMD globals are allowed.