mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Avoid a crash with @typedef in a script file. (#33847)
* Avoid a crash with `@typedef` in a script file. Scripts (as opposed to modules) do not have a symbol object. If a script contains a `@typdef` defined on a namespace called `exports`, TypeScript crashes because it attempts to create an exported symbol on the (non-existent) symbol of the SourceFile. This change avoids the crash by explicitly checking if the source file has a symbol object, i.e. whether it is a module. * Add usage of exports.SomeName typedef. * Fix bug at bind site rather than in declare func
This commit is contained in:
committed by
Wesley Wigham
parent
7cfa1dfb8a
commit
a03227d60e
@@ -2003,7 +2003,12 @@ namespace ts {
|
||||
switch (getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
|
||||
case AssignmentDeclarationKind.ExportsProperty:
|
||||
case AssignmentDeclarationKind.ModuleExports:
|
||||
container = file;
|
||||
if (!isExternalOrCommonJsModule(file)) {
|
||||
container = undefined!;
|
||||
}
|
||||
else {
|
||||
container = file;
|
||||
}
|
||||
break;
|
||||
case AssignmentDeclarationKind.ThisProperty:
|
||||
container = declName.parent.expression;
|
||||
@@ -2017,7 +2022,9 @@ namespace ts {
|
||||
case AssignmentDeclarationKind.None:
|
||||
return Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
|
||||
}
|
||||
declareModuleMember(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
|
||||
if (container) {
|
||||
declareModuleMember(typeAlias, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes);
|
||||
}
|
||||
container = oldContainer;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user