Update to push types through as well

This commit is contained in:
Ryan Cavanaugh 2016-03-01 12:26:17 -08:00
parent 50eca44e46
commit 1f9153f801
3 changed files with 55 additions and 22 deletions

View File

@ -2958,12 +2958,22 @@ namespace ts {
function getTypeOfAccessors(symbol: Symbol): Type {
const links = getSymbolLinks(symbol);
if (!links.type) {
const getter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.GetAccessor);
const setter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.SetAccessor);
if (getter.flags & NodeFlags.JavaScriptFile) {
const jsDocType = getTypeForVariableLikeDeclarationFromJSDocComment(getter);
if (jsDocType) {
return links.type = jsDocType;
}
}
if (!pushTypeResolution(symbol, TypeSystemPropertyName.Type)) {
return unknownType;
}
const getter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.GetAccessor);
const setter = <AccessorDeclaration>getDeclarationOfKind(symbol, SyntaxKind.SetAccessor);
let type: Type;
// First try to see if the user specified a return type on the get-accessor.
const getterReturnType = getAnnotatedAccessorType(getter);
if (getterReturnType) {

View File

@ -2,25 +2,19 @@
// @allowNonTsExtensions: true
// @Filename: file.js
//// let x = {
//// /** This is cool*/
//// get m() {
//// return 0;
//// }
//// /**
//// * This is a very cool function that is very nice.
//// * @returns something
//// * @param p anotherthing
//// */
//// function a1(p) {
//// try {
//// throw new Error('x');
//// } catch (x) { x--; }
//// return 23;
//// }
//// x.m/*1*/;
////
//// class Foo {
//// /** This is cool too*/
//// get b() {
//// return 0;
//// }
//// }
//// var y = new Foo();
//// y.b/*2*/;
////
//// x - /**/a1()
goTo.marker('1');
verify.quickInfoIs(undefined, 'This is cool');
goTo.marker('2');
verify.quickInfoIs(undefined, 'This is cool too');
goTo.marker();
verify.quickInfoExists();

View File

@ -0,0 +1,29 @@
/// <reference path="fourslash.ts" />
// @allowNonTsExtensions: true
// @Filename: file.js
//// let x = {
//// /** @type {number} */
//// get m() {
//// return undefined;
//// }
//// }
//// x.m/*1*/;
////
//// class Foo {
//// /** @type {string} */
//// get b() {
//// return undefined;
//// }
//// }
//// var y = new Foo();
//// y.b/*2*/;
goTo.marker('1');
edit.insert('.');
verify.memberListContains('toFixed', undefined, undefined, 'method');
edit.backspace();
goTo.marker('2');
edit.insert('.');
verify.memberListContains('substr', undefined, undefined, 'method');