mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 12:32:08 -06:00
Don't crash when observing invalid exports in any kind of container (#59376)
This commit is contained in:
parent
71fb864138
commit
a4ae3c46b6
@ -69,7 +69,6 @@ import {
|
||||
modifierToFlag,
|
||||
ModuleBlock,
|
||||
Node,
|
||||
ObjectLiteralExpression,
|
||||
ObjectTypeDeclaration,
|
||||
Program,
|
||||
ReturnStatement,
|
||||
@ -294,7 +293,7 @@ export namespace DocumentHighlights {
|
||||
|
||||
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 | ObjectLiteralExpression;
|
||||
const container = declaration.parent as ModuleBlock | SourceFile | Block | CaseClause | DefaultClause | ConstructorDeclaration | MethodDeclaration | FunctionDeclaration | ObjectTypeDeclaration;
|
||||
switch (container.kind) {
|
||||
case SyntaxKind.ModuleBlock:
|
||||
case SyntaxKind.SourceFile:
|
||||
@ -332,11 +331,8 @@ export namespace DocumentHighlights {
|
||||
return nodes;
|
||||
|
||||
// Syntactically invalid positions that the parser might produce anyway
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return undefined;
|
||||
|
||||
default:
|
||||
Debug.assertNever(container, "Invalid container kind.");
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
// === documentHighlights ===
|
||||
// filesToSearch:
|
||||
// /tests/cases/fourslash/a.ts
|
||||
|
||||
// === /tests/cases/fourslash/a.ts ===
|
||||
// subTitle:
|
||||
// /*HIGHLIGHTS*/export const title: string
|
||||
8
tests/cases/fourslash/exportInLabeledStatement.ts
Normal file
8
tests/cases/fourslash/exportInLabeledStatement.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: a.ts
|
||||
//// subTitle:
|
||||
//// [|export|] const title: string
|
||||
|
||||
verify.baselineDocumentHighlights(test.ranges()[0], { filesToSearch: [test.ranges()[0].fileName] });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user