diff --git a/integration/language_service_plugin/goldens/quickinfo.json b/integration/language_service_plugin/goldens/quickinfo.json index 5171068d64..a30b8c66c1 100644 --- a/integration/language_service_plugin/goldens/quickinfo.json +++ b/integration/language_service_plugin/goldens/quickinfo.json @@ -15,7 +15,7 @@ "line": 5, "offset": 30 }, - "displayString": "(property) AppComponent.name", + "displayString": "(property) AppComponent.name: string", "documentation": "", "tags": [] } diff --git a/packages/language-service/src/hover.ts b/packages/language-service/src/hover.ts index 9860f7eb3f..04c3a28a80 100644 --- a/packages/language-service/src/hover.ts +++ b/packages/language-service/src/hover.ts @@ -18,6 +18,7 @@ const SYMBOL_SPACE = ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.space]; const SYMBOL_PUNC = ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.punctuation]; const SYMBOL_CLASS = ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.className]; const SYMBOL_TEXT = ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.text]; +const SYMBOL_INTERFACE = ts.SymbolDisplayPartKind[ts.SymbolDisplayPartKind.interfaceName]; /** * Traverse the template AST and look for the symbol located at `position`, then @@ -45,19 +46,28 @@ export function getHover(info: AstResult, position: number, host: Readonly { expect(quickInfo).toBeTruthy(); const {textSpan, displayParts} = quickInfo !; expect(textSpan).toEqual(marker); - expect(toText(displayParts)).toBe('(property) MyComponent.name'); + expect(toText(displayParts)).toBe('(property) MyComponent.name: string'); }); it('should be able to find a field in a attribute reference', () => { @@ -52,7 +52,7 @@ describe('hover', () => { expect(quickInfo).toBeTruthy(); const {textSpan, displayParts} = quickInfo !; expect(textSpan).toEqual(marker); - expect(toText(displayParts)).toBe('(property) MyComponent.name'); + expect(toText(displayParts)).toBe('(property) MyComponent.name: string'); }); it('should be able to find a method from a call', () => { @@ -69,7 +69,7 @@ describe('hover', () => { const {textSpan, displayParts} = quickInfo !; expect(textSpan).toEqual(marker); expect(textSpan.length).toBe('myClick()'.length); - expect(toText(displayParts)).toBe('(method) MyComponent.myClick'); + expect(toText(displayParts)).toBe('(method) MyComponent.myClick: () => void'); }); it('should be able to find a field reference in an *ngIf', () => { @@ -85,7 +85,7 @@ describe('hover', () => { expect(quickInfo).toBeTruthy(); const {textSpan, displayParts} = quickInfo !; expect(textSpan).toEqual(marker); - expect(toText(displayParts)).toBe('(property) MyComponent.include'); + expect(toText(displayParts)).toBe('(property) MyComponent.include: boolean'); }); it('should be able to find a reference to a component', () => { @@ -113,7 +113,7 @@ describe('hover', () => { expect(quickInfo).toBeTruthy(); const {textSpan, displayParts} = quickInfo !; expect(textSpan).toEqual(marker); - expect(toText(displayParts)).toBe('(directive) StringModel'); + expect(toText(displayParts)).toBe('(directive) StringModel: typeof StringModel'); }); it('should be able to find an event provider', () => { @@ -129,7 +129,7 @@ describe('hover', () => { expect(quickInfo).toBeTruthy(); const {textSpan, displayParts} = quickInfo !; expect(textSpan).toEqual(marker); - expect(toText(displayParts)).toBe('(event) TestComponent.testEvent'); + expect(toText(displayParts)).toBe('(event) TestComponent.testEvent: EventEmitter'); }); it('should be able to find an input provider', () => { @@ -145,7 +145,7 @@ describe('hover', () => { expect(quickInfo).toBeTruthy(); const {textSpan, displayParts} = quickInfo !; expect(textSpan).toEqual(marker); - expect(toText(displayParts)).toBe('(property) TestComponent.name'); + expect(toText(displayParts)).toBe('(property) TestComponent.name: string'); }); it('should be able to ignore a reference declaration', () => { @@ -203,7 +203,7 @@ describe('hover', () => { start: position, length: '$any(title)'.length, }); - expect(toText(displayParts)).toBe('(method) $any'); + expect(toText(displayParts)).toBe('(method) $any: $any'); }); });