Skip to content

Commit 14bd0a2

Browse files
author
Andy
authored
Detect and prevent creation of bad Identifier (microsoft#21581)
1 parent c03ee9d commit 14bd0a2

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5899,7 +5899,7 @@ namespace ts {
58995899

59005900
/** True if node is of a kind that may contain comment text. */
59015901
export function isJSDocCommentContainingNode(node: Node): boolean {
5902-
return node.kind === SyntaxKind.JSDocComment || isJSDocTag(node);
5902+
return node.kind === SyntaxKind.JSDocComment || isJSDocTag(node) || isJSDocTypeLiteral(node);
59035903
}
59045904

59055905
// TODO: determine what this does before making it public.

src/services/services.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,15 @@ namespace ts {
114114
return sourceFile.text.substring(this.getStart(sourceFile), this.getEnd());
115115
}
116116

117-
private addSyntheticNodes(nodes: Node[], pos: number, end: number): number {
117+
private addSyntheticNodes(nodes: Push<Node>, pos: number, end: number): number {
118118
scanner.setTextPos(pos);
119119
while (pos < end) {
120120
const token = scanner.scan();
121121
const textPos = scanner.getTextPos();
122122
if (textPos <= end) {
123+
if (token === SyntaxKind.Identifier) {
124+
Debug.fail(`Did not expect ${(ts as any).SyntaxKind[this.kind]} to have an Identifier in its trivia`);
125+
}
123126
nodes.push(createNode(token, pos, textPos, this));
124127
}
125128
pos = textPos;

tests/cases/fourslash/findAllReferencesJsDocTypeLiteral.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,3 @@
1414
//// function f(o) { return o.nested.[|great|]; }
1515

1616
verify.rangesReferenceEachOther();
17-
18-
///**
19-
// * @param {object} [|o|] - very important!
20-
// * @param {string} o.x - a thing, its ok
21-
// */
22-
// function f([|o|]) { return [|o|].x; }

0 commit comments

Comments
 (0)