File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -311,17 +311,21 @@ namespace ts.SymbolDisplay {
311311 }
312312 if ( symbolFlags & SymbolFlags . Class && ! hasAddedSymbolInfo && ! isThisExpression ) {
313313 addAliasPrefixIfNecessary ( ) ;
314- if ( getDeclarationOfKind ( symbol , SyntaxKind . ClassExpression ) ) {
315- // Special case for class expressions because we would like to indicate that
314+ if ( getDeclarationOfKind ( symbol , SyntaxKind . ClassExpression ) && ! alias ) {
315+ // Special case for named class expressions because we would like to indicate that
316316 // the class name is local to the class body (similar to function expression)
317317 // (local class) class <className>
318- pushSymbolKind ( ScriptElementKind . localClassElement ) ;
318+ // anonymous class expressions should only print as "(Anonymous class)"
319+ if ( symbol . name !== InternalSymbolName . Class ) {
320+ pushSymbolKind ( ScriptElementKind . localClassElement ) ;
321+ displayParts . push ( spacePart ( ) ) ;
322+ }
319323 }
320324 else {
321325 // Class declaration has name which is not local.
322326 displayParts . push ( keywordPart ( SyntaxKind . ClassKeyword ) ) ;
327+ displayParts . push ( spacePart ( ) ) ;
323328 }
324- displayParts . push ( spacePart ( ) ) ;
325329 addFullSymbolName ( symbol ) ;
326330 writeTypeParametersOfSymbol ( symbol , sourceFile ) ;
327331 }
Original file line number Diff line number Diff line change 7777 "containerName" : " " ,
7878 "fileName" : " /b.ts" ,
7979 "kind" : " alias" ,
80- "name" : " (alias) (local class) A\n import A = require(\" ./a\" )" ,
80+ "name" : " (alias) class A\n import A = require(\" ./a\" )" ,
8181 "textSpan" : {
8282 "start" : 7 ,
8383 "length" : 1
100100 "kind" : " space"
101101 },
102102 {
103- "text" : " (" ,
104- "kind" : " punctuation"
105- },
106- {
107- "text" : " local class" ,
108- "kind" : " text"
109- },
110- {
111- "text" : " )" ,
112- "kind" : " punctuation"
103+ "text" : " class" ,
104+ "kind" : " keyword"
113105 },
114106 {
115107 "text" : " " ,
273265 "containerName" : " " ,
274266 "fileName" : " /b.ts" ,
275267 "kind" : " alias" ,
276- "name" : " (alias) (local class) A\n import A = require(\" ./a\" )" ,
268+ "name" : " (alias) class A\n import A = require(\" ./a\" )" ,
277269 "textSpan" : {
278270 "start" : 7 ,
279271 "length" : 1
296288 "kind" : " space"
297289 },
298290 {
299- "text" : " (" ,
300- "kind" : " punctuation"
301- },
302- {
303- "text" : " local class" ,
304- "kind" : " text"
305- },
306- {
307- "text" : " )" ,
308- "kind" : " punctuation"
291+ "text" : " class" ,
292+ "kind" : " keyword"
309293 },
310294 {
311295 "text" : " " ,
406390 "containerName" : " " ,
407391 "fileName" : " /b.ts" ,
408392 "kind" : " alias" ,
409- "name" : " (alias) (local class) A\n import A = require(\" ./a\" )" ,
393+ "name" : " (alias) class A\n import A = require(\" ./a\" )" ,
410394 "textSpan" : {
411395 "start" : 7 ,
412396 "length" : 1
429413 "kind" : " space"
430414 },
431415 {
432- "text" : " (" ,
433- "kind" : " punctuation"
434- },
435- {
436- "text" : " local class" ,
437- "kind" : " text"
438- },
439- {
440- "text" : " )" ,
441- "kind" : " punctuation"
416+ "text" : " class" ,
417+ "kind" : " keyword"
442418 },
443419 {
444420 "text" : " " ,
604580 "containerName" : " " ,
605581 "fileName" : " /b.ts" ,
606582 "kind" : " alias" ,
607- "name" : " (alias) (local class) A\n import A = require(\" ./a\" )" ,
583+ "name" : " (alias) class A\n import A = require(\" ./a\" )" ,
608584 "textSpan" : {
609585 "start" : 7 ,
610586 "length" : 1
627603 "kind" : " space"
628604 },
629605 {
630- "text" : " (" ,
631- "kind" : " punctuation"
632- },
633- {
634- "text" : " local class" ,
635- "kind" : " text"
636- },
637- {
638- "text" : " )" ,
639- "kind" : " punctuation"
606+ "text" : " class" ,
607+ "kind" : " keyword"
640608 },
641609 {
642610 "text" : " " ,
Original file line number Diff line number Diff line change 6666 "containerName" : " " ,
6767 "fileName" : " /b.js" ,
6868 "kind" : " alias" ,
69- "name" : " (alias) (local class) A\n import A = require(\" ./a\" )" ,
69+ "name" : " (alias) class A\n import A = require(\" ./a\" )" ,
7070 "textSpan" : {
7171 "start" : 7 ,
7272 "length" : 1
8989 "kind" : " space"
9090 },
9191 {
92- "text" : " (" ,
93- "kind" : " punctuation"
94- },
95- {
96- "text" : " local class" ,
97- "kind" : " text"
98- },
99- {
100- "text" : " )" ,
101- "kind" : " punctuation"
92+ "text" : " class" ,
93+ "kind" : " keyword"
10294 },
10395 {
10496 "text" : " " ,
199191 "containerName" : " " ,
200192 "fileName" : " /b.js" ,
201193 "kind" : " alias" ,
202- "name" : " (alias) (local class) A\n import A = require(\" ./a\" )" ,
194+ "name" : " (alias) class A\n import A = require(\" ./a\" )" ,
203195 "textSpan" : {
204196 "start" : 7 ,
205197 "length" : 1
222214 "kind" : " space"
223215 },
224216 {
225- "text" : " (" ,
226- "kind" : " punctuation"
227- },
228- {
229- "text" : " local class" ,
230- "kind" : " text"
231- },
232- {
233- "text" : " )" ,
234- "kind" : " punctuation"
217+ "text" : " class" ,
218+ "kind" : " keyword"
235219 },
236220 {
237221 "text" : " " ,
386370 "containerName" : " " ,
387371 "fileName" : " /b.js" ,
388372 "kind" : " alias" ,
389- "name" : " (alias) (local class) A\n import A = require(\" ./a\" )" ,
373+ "name" : " (alias) class A\n import A = require(\" ./a\" )" ,
390374 "textSpan" : {
391375 "start" : 7 ,
392376 "length" : 1
409393 "kind" : " space"
410394 },
411395 {
412- "text" : " (" ,
413- "kind" : " punctuation"
414- },
415- {
416- "text" : " local class" ,
417- "kind" : " text"
418- },
419- {
420- "text" : " )" ,
421- "kind" : " punctuation"
396+ "text" : " class" ,
397+ "kind" : " keyword"
422398 },
423399 {
424400 "text" : " " ,
Original file line number Diff line number Diff line change 1212 "containerName" : " " ,
1313 "fileName" : " /a.js" ,
1414 "kind" : " alias" ,
15- "name" : " (alias) (local class) A\n import A" ,
15+ "name" : " (alias) class A\n import A" ,
1616 "textSpan" : {
1717 "start" : 8 ,
1818 "length" : 1
3535 "kind" : " space"
3636 },
3737 {
38- "text" : " (" ,
39- "kind" : " punctuation"
40- },
41- {
42- "text" : " local class" ,
43- "kind" : " text"
44- },
45- {
46- "text" : " )" ,
47- "kind" : " punctuation"
38+ "text" : " class" ,
39+ "kind" : " keyword"
4840 },
4941 {
5042 "text" : " " ,
9890 "containerName" : " " ,
9991 "fileName" : " /b.js" ,
10092 "kind" : " alias" ,
101- "name" : " (alias) (local class) A\n import A" ,
93+ "name" : " (alias) class A\n import A" ,
10294 "textSpan" : {
10395 "start" : 9 ,
10496 "length" : 1
121113 "kind" : " space"
122114 },
123115 {
124- "text" : " (" ,
125- "kind" : " punctuation"
126- },
127- {
128- "text" : " local class" ,
129- "kind" : " text"
130- },
131- {
132- "text" : " )" ,
133- "kind" : " punctuation"
116+ "text" : " class" ,
117+ "kind" : " keyword"
134118 },
135119 {
136120 "text" : " " ,
203187 "containerName" : " " ,
204188 "fileName" : " /b.js" ,
205189 "kind" : " alias" ,
206- "name" : " (alias) (local class) A\n import A" ,
190+ "name" : " (alias) class A\n import A" ,
207191 "textSpan" : {
208192 "start" : 9 ,
209193 "length" : 1
226210 "kind" : " space"
227211 },
228212 {
229- "text" : " (" ,
230- "kind" : " punctuation"
231- },
232- {
233- "text" : " local class" ,
234- "kind" : " text"
235- },
236- {
237- "text" : " )" ,
238- "kind" : " punctuation"
213+ "text" : " class" ,
214+ "kind" : " keyword"
239215 },
240216 {
241217 "text" : " " ,
298274 "containerName" : " " ,
299275 "fileName" : " /a.js" ,
300276 "kind" : " alias" ,
301- "name" : " (alias) (local class) A\n import A" ,
277+ "name" : " (alias) class A\n import A" ,
302278 "textSpan" : {
303279 "start" : 8 ,
304280 "length" : 1
321297 "kind" : " space"
322298 },
323299 {
324- "text" : " (" ,
325- "kind" : " punctuation"
326- },
327- {
328- "text" : " local class" ,
329- "kind" : " text"
330- },
331- {
332- "text" : " )" ,
333- "kind" : " punctuation"
300+ "text" : " class" ,
301+ "kind" : " keyword"
334302 },
335303 {
336304 "text" : " " ,
394362 "containerName" : " " ,
395363 "fileName" : " /b.js" ,
396364 "kind" : " alias" ,
397- "name" : " (alias) (local class) A\n import A" ,
365+ "name" : " (alias) class A\n import A" ,
398366 "textSpan" : {
399367 "start" : 9 ,
400368 "length" : 1
417385 "kind" : " space"
418386 },
419387 {
420- "text" : " (" ,
421- "kind" : " punctuation"
422- },
423- {
424- "text" : " local class" ,
425- "kind" : " text"
426- },
427- {
428- "text" : " )" ,
429- "kind" : " punctuation"
388+ "text" : " class" ,
389+ "kind" : " keyword"
430390 },
431391 {
432392 "text" : " " ,
487447 "containerName" : " " ,
488448 "fileName" : " /a.js" ,
489449 "kind" : " alias" ,
490- "name" : " (alias) (local class) A\n import A" ,
450+ "name" : " (alias) class A\n import A" ,
491451 "textSpan" : {
492452 "start" : 8 ,
493453 "length" : 1
510470 "kind" : " space"
511471 },
512472 {
513- "text" : " (" ,
514- "kind" : " punctuation"
515- },
516- {
517- "text" : " local class" ,
518- "kind" : " text"
519- },
520- {
521- "text" : " )" ,
522- "kind" : " punctuation"
473+ "text" : " class" ,
474+ "kind" : " keyword"
523475 },
524476 {
525477 "text" : " " ,
You can’t perform that action at this time.
0 commit comments