mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 01:49:57 -05:00
Don't crash when observing invalid 'export' in object literal (#40295)
Fixes #32870
This commit is contained in:
@@ -204,7 +204,7 @@ namespace ts {
|
||||
|
||||
function getNodesToSearchForModifier(declaration: Node, modifierFlag: ModifierFlags): readonly Node[] | undefined {
|
||||
// Types of node whose children might have modifiers.
|
||||
const container = declaration.parent as ModuleBlock | SourceFile | Block | CaseClause | DefaultClause | ConstructorDeclaration | MethodDeclaration | FunctionDeclaration | ObjectTypeDeclaration;
|
||||
const container = declaration.parent as ModuleBlock | SourceFile | Block | CaseClause | DefaultClause | ConstructorDeclaration | MethodDeclaration | FunctionDeclaration | ObjectTypeDeclaration | ObjectLiteralExpression;
|
||||
switch (container.kind) {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.SourceFile:
|
||||
@@ -240,6 +240,11 @@ namespace ts {
|
||||
return [...nodes, container];
|
||||
}
|
||||
return nodes;
|
||||
|
||||
// Syntactically invalid positions that the parser might produce anyway
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return undefined;
|
||||
|
||||
default:
|
||||
Debug.assertNever(container, "Invalid container kind.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user