Don’t emit diagnostic accessing UMD globals from modules when flag is set

This commit is contained in:
Andrew Branch 2019-04-05 11:09:16 -07:00
parent 6d1d680c0e
commit 11e45162ea
No known key found for this signature in database
GPG Key ID: 22CCA4B120C427D2

View File

@ -1632,10 +1632,10 @@ namespace ts {
}
// If we're in an external module, we can't reference value symbols created from UMD export declarations
if (result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value && !(originalLocation!.flags & NodeFlags.JSDoc)) {
if (!compilerOptions.allowUmdGlobalAccess && result && isInExternalModule && (meaning & SymbolFlags.Value) === SymbolFlags.Value && !(originalLocation!.flags & NodeFlags.JSDoc)) {
const merged = getMergedSymbol(result);
if (length(merged.declarations) && every(merged.declarations, d => isNamespaceExportDeclaration(d) || isSourceFile(d) && !!d.symbol.globalExports)) {
error(errorLocation!, Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, unescapeLeadingUnderscores(name)); // TODO: GH#18217
error(errorLocation!, Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, unescapeLeadingUnderscores(name));
}
}
}