mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Merge pull request #28782 from weswigham/global-merge-no-crash
Fix crash on umd and module merge, allow umds to be accessed when merged with a non-UMD symbol
This commit is contained in:
@@ -1569,7 +1569,8 @@ 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 (some(result.declarations, d => isNamespaceExportDeclaration(d) || isSourceFile(d) && !!d.symbol.globalExports)) {
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -5322,12 +5323,11 @@ namespace ts {
|
||||
return anyType;
|
||||
}
|
||||
// Handle export default expressions
|
||||
if (isSourceFile(declaration)) {
|
||||
const jsonSourceFile = cast(declaration, isJsonSourceFile);
|
||||
if (!jsonSourceFile.statements.length) {
|
||||
if (isSourceFile(declaration) && isJsonSourceFile(declaration)) {
|
||||
if (!declaration.statements.length) {
|
||||
return emptyObjectType;
|
||||
}
|
||||
const type = getWidenedLiteralType(checkExpression(jsonSourceFile.statements[0].expression));
|
||||
const type = getWidenedLiteralType(checkExpression(declaration.statements[0].expression));
|
||||
if (type.flags & TypeFlags.Object) {
|
||||
return getRegularTypeOfObjectLiteral(type);
|
||||
}
|
||||
@@ -5352,7 +5352,8 @@ namespace ts {
|
||||
|| isClassDeclaration(declaration)
|
||||
|| isFunctionDeclaration(declaration)
|
||||
|| (isMethodDeclaration(declaration) && !isObjectLiteralMethod(declaration))
|
||||
|| isMethodSignature(declaration)) {
|
||||
|| isMethodSignature(declaration)
|
||||
|| isSourceFile(declaration)) {
|
||||
// Symbol is property of some kind that is merged with something - should use `getTypeOfFuncClassEnumModule` and not `getTypeOfVariableOrParameterOrProperty`
|
||||
if (symbol.flags & (SymbolFlags.Function | SymbolFlags.Method | SymbolFlags.Class | SymbolFlags.Enum | SymbolFlags.ValueModule)) {
|
||||
return getTypeOfFuncClassEnumModule(symbol);
|
||||
|
||||
Reference in New Issue
Block a user