Merge pull request #16133 from Microsoft/master-fix15824

[Master] Fix 15824 - consider function same as Function in jsdoc
This commit is contained in:
Yui 2017-05-30 08:07:15 -07:00 committed by GitHub
commit bebe2de021
7 changed files with 49 additions and 31 deletions

View File

@ -6855,6 +6855,7 @@ namespace ts {
case "Object":
return anyType;
case "Function":
case "function":
return globalFunctionType;
case "Array":
case "array":

View File

@ -6075,7 +6075,10 @@ namespace ts {
case SyntaxKind.OpenBraceToken:
return parseJSDocRecordType();
case SyntaxKind.FunctionKeyword:
return parseJSDocFunctionType();
if (lookAhead(nextTokenIsOpenParen)) {
return parseJSDocFunctionType();
}
break;
case SyntaxKind.DotDotDotToken:
return parseJSDocVariadicType();
case SyntaxKind.NewKeyword:

View File

@ -431,28 +431,8 @@
"kind": "space"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=>",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "any",
"kind": "keyword"
"text": "Function",
"kind": "localName"
}
],
"documentation": [],

View File

@ -11,6 +11,10 @@ anyT1 = "hi";
const x = (a) => a + 1;
x(1);
/** @type {function} */
const y = (a) => a + 1;
x(1);
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1(0);
@ -29,6 +33,9 @@ anyT1 = "hi";
/** @type {Function} */
var x = function (a) { return a + 1; };
x(1);
/** @type {function} */
var y = function (a) { return a + 1; };
x(1);
/** @type {function (number)} */
var x1 = function (a) { return a + 1; };
x1(0);

View File

@ -20,21 +20,30 @@ const x = (a) => a + 1;
x(1);
>x : Symbol(x, Decl(0.js, 9, 5))
/** @type {function} */
const y = (a) => a + 1;
>y : Symbol(y, Decl(0.js, 13, 5))
>a : Symbol(a, Decl(0.js, 13, 11))
>a : Symbol(a, Decl(0.js, 13, 11))
x(1);
>x : Symbol(x, Decl(0.js, 9, 5))
/** @type {function (number)} */
const x1 = (a) => a + 1;
>x1 : Symbol(x1, Decl(0.js, 13, 5))
>a : Symbol(a, Decl(0.js, 13, 12))
>a : Symbol(a, Decl(0.js, 13, 12))
>x1 : Symbol(x1, Decl(0.js, 17, 5))
>a : Symbol(a, Decl(0.js, 17, 12))
>a : Symbol(a, Decl(0.js, 17, 12))
x1(0);
>x1 : Symbol(x1, Decl(0.js, 13, 5))
>x1 : Symbol(x1, Decl(0.js, 17, 5))
/** @type {function (number): number} */
const x2 = (a) => a + 1;
>x2 : Symbol(x2, Decl(0.js, 17, 5))
>a : Symbol(a, Decl(0.js, 17, 12))
>a : Symbol(a, Decl(0.js, 17, 12))
>x2 : Symbol(x2, Decl(0.js, 21, 5))
>a : Symbol(a, Decl(0.js, 21, 12))
>a : Symbol(a, Decl(0.js, 21, 12))
x2(0);
>x2 : Symbol(x2, Decl(0.js, 17, 5))
>x2 : Symbol(x2, Decl(0.js, 21, 5))

View File

@ -29,6 +29,20 @@ x(1);
>x : Function
>1 : 1
/** @type {function} */
const y = (a) => a + 1;
>y : Function
>(a) => a + 1 : (a: any) => any
>a : any
>a + 1 : any
>a : any
>1 : 1
x(1);
>x(1) : any
>x : Function
>1 : 1
/** @type {function (number)} */
const x1 = (a) => a + 1;
>x1 : (arg0: number) => any

View File

@ -14,6 +14,10 @@ anyT1 = "hi";
const x = (a) => a + 1;
x(1);
/** @type {function} */
const y = (a) => a + 1;
x(1);
/** @type {function (number)} */
const x1 = (a) => a + 1;
x1(0);