Skip to content

Commit 159b626

Browse files
authored
Merge pull request microsoft#34631 from amcasey/ComputedPropName
Handle undefined from getPropertyNameForPropertyNameNode
2 parents 8cf1324 + 7862e58 commit 159b626

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

src/services/navigationBar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,8 @@ namespace ts.NavigationBar {
648648

649649
const declName = getNameOfDeclaration(<Declaration>node);
650650
if (declName && isPropertyName(declName)) {
651-
return unescapeLeadingUnderscores(getPropertyNameForPropertyNameNode(declName)!); // TODO: GH#18217
651+
const propertyName = getPropertyNameForPropertyNameNode(declName);
652+
return propertyName && unescapeLeadingUnderscores(propertyName);
652653
}
653654
switch (node.kind) {
654655
case SyntaxKind.FunctionExpression:
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
////function F(key, value) {
4+
//// return {
5+
//// [key]: value,
6+
//// "prop": true
7+
//// }
8+
////}
9+
10+
verify.navigationTree({
11+
"text": "<global>",
12+
"kind": "script",
13+
"childItems": [
14+
{
15+
"text": "F",
16+
"kind": "function",
17+
"childItems": [
18+
{
19+
"text": "[key]",
20+
"kind": "property"
21+
},
22+
{
23+
"text": "\"prop\"",
24+
"kind": "property"
25+
}
26+
]
27+
}
28+
]
29+
});
30+
31+
verify.navigationBar([
32+
{
33+
"text": "<global>",
34+
"kind": "script",
35+
"childItems": [
36+
{
37+
"text": "F",
38+
"kind": "function"
39+
}
40+
]
41+
},
42+
{
43+
"text": "F",
44+
"kind": "function",
45+
"childItems": [
46+
{
47+
"text": "[key]",
48+
"kind": "property"
49+
},
50+
{
51+
"text": "\"prop\"",
52+
"kind": "property"
53+
}
54+
],
55+
"indent": 1
56+
}
57+
]);

0 commit comments

Comments
 (0)