PR Feedback

This commit is contained in:
Ron Buckton 2017-06-08 11:27:35 -07:00
parent 6bbacb64ce
commit 80a7716117
5 changed files with 123 additions and 11 deletions

View file

@ -12744,9 +12744,11 @@ namespace ts {
if (declaration.type) {
return getTypeFromTypeNode(declaration.type);
}
const jsDocType = isInJavaScriptFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration);
if (jsDocType) {
return jsDocType;
if (isInJavaScriptFile(declaration)) {
const jsDocType = getTypeForDeclarationFromJSDocComment(declaration);
if (jsDocType) {
return jsDocType;
}
}
if (declaration.kind === SyntaxKind.Parameter) {
const type = getContextuallyTypedParameterType(<ParameterDeclaration>declaration);

View file

@ -2625,13 +2625,11 @@ namespace ts {
if (accessor && accessor.parameters.length > 0) {
const hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]);
const parameter = accessor.parameters[hasThis ? 1 : 0];
if (parameter) {
if (parameter.type) {
return parameter.type;
}
if (includeJSDocType && parameter.flags & NodeFlags.JavaScriptFile) {
return getJSDocType(parameter);
}
if (parameter.type) {
return parameter.type;
}
if (includeJSDocType && parameter.flags & NodeFlags.JavaScriptFile) {
return getJSDocType(parameter);
}
}
}

View file

@ -10,3 +10,39 @@ const arr = [
>y : Symbol(y, Decl(index.js, 3, 11))
];
/** @return {function(): Array<[string, {x?:number, y?:number}]>} */
function f() {
>f : Symbol(f, Decl(index.js, 4, 2))
return [
['a', { x: 1 }],
>x : Symbol(x, Decl(index.js, 9, 15))
['b', { y: 2 }]
>y : Symbol(y, Decl(index.js, 10, 15))
];
}
class C {
>C : Symbol(C, Decl(index.js, 12, 1))
/** @param {function(): Array<[string, {x?:number, y?:number}]>} value */
set x(value) { }
>x : Symbol(C.x, Decl(index.js, 14, 9))
>value : Symbol(value, Decl(index.js, 16, 10))
get () {
>get : Symbol(C.get, Decl(index.js, 16, 20))
return [
['a', { x: 1 }],
>x : Symbol(x, Decl(index.js, 19, 19))
['b', { y: 2 }]
>y : Symbol(y, Decl(index.js, 20, 19))
];
}
}

View file

@ -19,3 +19,59 @@ const arr = [
>2 : 2
];
/** @return {function(): Array<[string, {x?:number, y?:number}]>} */
function f() {
>f : () => () => [string, { x?: number; y?: number; }][]
return [
>[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ((string | { [x: string]: any; x: number; })[] | (string | { [x: string]: any; y: number; })[])[]
['a', { x: 1 }],
>['a', { x: 1 }] : (string | { [x: string]: any; x: number; })[]
>'a' : "a"
>{ x: 1 } : { [x: string]: any; x: number; }
>x : number
>1 : 1
['b', { y: 2 }]
>['b', { y: 2 }] : (string | { [x: string]: any; y: number; })[]
>'b' : "b"
>{ y: 2 } : { [x: string]: any; y: number; }
>y : number
>2 : 2
];
}
class C {
>C : C
/** @param {function(): Array<[string, {x?:number, y?:number}]>} value */
set x(value) { }
>x : any
>value : () => [string, { x?: number; y?: number; }][]
get () {
>get : () => ((string | { [x: string]: any; x: number; })[] | (string | { [x: string]: any; y: number; })[])[]
return [
>[ ['a', { x: 1 }], ['b', { y: 2 }] ] : ((string | { [x: string]: any; x: number; })[] | (string | { [x: string]: any; y: number; })[])[]
['a', { x: 1 }],
>['a', { x: 1 }] : (string | { [x: string]: any; x: number; })[]
>'a' : "a"
>{ x: 1 } : { [x: string]: any; x: number; }
>x : number
>1 : 1
['b', { y: 2 }]
>['b', { y: 2 }] : (string | { [x: string]: any; y: number; })[]
>'b' : "b"
>{ y: 2 } : { [x: string]: any; y: number; }
>y : number
>2 : 2
];
}
}

View file

@ -2,9 +2,29 @@
// @checkJs: true
// @noEmit: true
// @filename: index.js
// @target: esnext
/** @type {Array<[string, {x?:number, y?:number}]>} */
const arr = [
['a', { x: 1 }],
['b', { y: 2 }]
];
];
/** @return {function(): Array<[string, {x?:number, y?:number}]>} */
function f() {
return [
['a', { x: 1 }],
['b', { y: 2 }]
];
}
class C {
/** @param {function(): Array<[string, {x?:number, y?:number}]>} value */
set x(value) { }
get () {
return [
['a', { x: 1 }],
['b', { y: 2 }]
];
}
}