Merge pull request #30776 from andrewbranch/feature/10178

Add flag to allow access to UMD globals from modules
This commit is contained in:
Andrew Branch
2019-04-18 18:05:44 -07:00
committed by GitHub
20 changed files with 100 additions and 1 deletions

View File

@@ -1648,7 +1648,7 @@ namespace ts {
if (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
errorOrSuggestion(!compilerOptions.allowUmdGlobalAccess, errorLocation!, Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, unescapeLeadingUnderscores(name));
}
}
}

View File

@@ -588,6 +588,13 @@ namespace ts {
category: Diagnostics.Module_Resolution_Options,
description: Diagnostics.Do_not_resolve_the_real_path_of_symlinks,
},
{
name: "allowUmdGlobalAccess",
type: "boolean",
affectsSemanticDiagnostics: true,
category: Diagnostics.Module_Resolution_Options,
description: Diagnostics.Allow_accessing_UMD_globals_from_modules,
},
// Source Maps
{

View File

@@ -4946,5 +4946,9 @@
"Convert parameters to destructured object": {
"category": "Message",
"code": 95075
},
"Allow accessing UMD globals from modules.": {
"category": "Message",
"code": 95076
}
}

View File

@@ -4589,6 +4589,7 @@ namespace ts {
allowJs?: boolean;
/*@internal*/ allowNonTsExtensions?: boolean;
allowSyntheticDefaultImports?: boolean;
allowUmdGlobalAccess?: boolean;
allowUnreachableCode?: boolean;
allowUnusedLabels?: boolean;
alwaysStrict?: boolean; // Always combine with strict property