Don't crash when observing invalid 'export' in object literal (#40295)
Fixes #32870
This commit is contained in:
parent
d7cd405bb2
commit
ea51fabb7c
|
@ -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.");
|
||||
}
|
||||
|
|
9
tests/cases/fourslash/exportInObjectLiteral.ts
Normal file
9
tests/cases/fourslash/exportInObjectLiteral.ts
Normal file
|
@ -0,0 +1,9 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: a.ts
|
||||
//// const k = {
|
||||
//// [|export|] f() { }
|
||||
//// }
|
||||
|
||||
verify.documentHighlightsOf(test.ranges()[0], [], { filesToSearch: [test.ranges()[0].fileName] });
|
||||
|
Loading…
Reference in a new issue