Skip to content

Commit 1f9153f

Browse files
committed
Update to push types through as well
1 parent 50eca44 commit 1f9153f

File tree

3 files changed

+55
-22
lines changed

3 files changed

+55
-22
lines changed

src/compiler/checker.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,12 +2958,22 @@ namespace ts {
29582958
function getTypeOfAccessors(symbol: Symbol): Type {
29592959
const links = getSymbolLinks(symbol);
29602960
if (!links.type) {
2961+
const getter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.GetAccessor);
2962+
const setter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.SetAccessor);
2963+
2964+
if (getter.flags & NodeFlags.JavaScriptFile) {
2965+
const jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter);
2966+
if (jsDocType) {
2967+
return links.type = jsDocType;
2968+
}
2969+
}
2970+
29612971
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
29622972
return unknownType;
29632973
}
2964-
const getter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.GetAccessor);
2965-
const setter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.SetAccessor);
2974+
29662975
let type: Type;
2976+
29672977
// First try to see if the user specified a return type on the get-accessor.
29682978
const getterReturnType = getAnnotatedAccessorType(getter);
29692979
if (getterReturnType) {

tests/cases/fourslash/getJavaScriptQuickInfo7.ts

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,19 @@
22

33
// @allowNonTsExtensions: true
44
// @Filename: file.js
5-
//// let x = {
6-
//// /** This is cool*/
7-
//// get m() {
8-
//// return 0;
9-
//// }
5+
//// /**
6+
//// * This is a very cool function that is very nice.
7+
//// * @returns something
8+
//// * @param p anotherthing
9+
//// */
10+
//// function a1(p) {
11+
//// try {
12+
//// throw new Error('x');
13+
//// } catch (x) { x--; }
14+
//// return 23;
1015
//// }
11-
//// x.m/*1*/;
12-
////
13-
//// class Foo {
14-
//// /** This is cool too*/
15-
//// get b() {
16-
//// return 0;
17-
//// }
18-
//// }
19-
//// var y = new Foo();
20-
//// y.b/*2*/;
21-
22-
goTo.marker('1');
23-
verify.quickInfoIs(undefined, 'This is cool');
16+
////
17+
//// x - /**/a1()
2418

25-
goTo.marker('2');
26-
verify.quickInfoIs(undefined, 'This is cool too');
19+
goTo.marker();
20+
verify.quickInfoExists();
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @allowNonTsExtensions: true
4+
// @Filename: file.js
5+
//// let x = {
6+
//// /** @type {number} */
7+
//// get m() {
8+
//// return undefined;
9+
//// }
10+
//// }
11+
//// x.m/*1*/;
12+
////
13+
//// class Foo {
14+
//// /** @type {string} */
15+
//// get b() {
16+
//// return undefined;
17+
//// }
18+
//// }
19+
//// var y = new Foo();
20+
//// y.b/*2*/;
21+
22+
goTo.marker('1');
23+
edit.insert('.');
24+
verify.memberListContains('toFixed', undefined, undefined, 'method');
25+
edit.backspace();
26+
27+
goTo.marker('2');
28+
edit.insert('.');
29+
verify.memberListContains('substr', undefined, undefined, 'method');

0 commit comments

Comments
 (0)