Ignore newline and asterisk when parsing JSDoc typedef (#26775)

This commit is contained in:
Tim Schaub 2018-08-30 11:01:33 -06:00 committed by Nathan Shively-Sanders
parent 038f665171
commit 20a2b0cade
4 changed files with 68 additions and 1 deletions

View File

@ -6856,7 +6856,7 @@ namespace ts {
function parseTypedefTag(atToken: AtToken, tagName: Identifier, indent: number): JSDocTypedefTag {
const typeExpression = tryParseTypeExpression();
skipWhitespace();
skipWhitespaceOrAsterisk();
const typedefTag = <JSDocTypedefTag>createNode(SyntaxKind.JSDocTypedefTag, atToken.pos);
typedefTag.atToken = atToken;

View File

@ -0,0 +1,23 @@
=== tests/cases/conformance/jsdoc/mod1.js ===
/**
* @typedef {function(string): boolean}
* MyType
*/
/**
* Tries to use a type whose name is on a different
* line than the typedef tag.
* @param {MyType} func The function to call.
* @param {string} arg The argument to call it with.
* @returns {boolean} The return.
*/
function callIt(func, arg) {
>callIt : Symbol(callIt, Decl(mod1.js, 0, 0))
>func : Symbol(func, Decl(mod1.js, 12, 16))
>arg : Symbol(arg, Decl(mod1.js, 12, 21))
return func(arg);
>func : Symbol(func, Decl(mod1.js, 12, 16))
>arg : Symbol(arg, Decl(mod1.js, 12, 21))
}

View File

@ -0,0 +1,24 @@
=== tests/cases/conformance/jsdoc/mod1.js ===
/**
* @typedef {function(string): boolean}
* MyType
*/
/**
* Tries to use a type whose name is on a different
* line than the typedef tag.
* @param {MyType} func The function to call.
* @param {string} arg The argument to call it with.
* @returns {boolean} The return.
*/
function callIt(func, arg) {
>callIt : (func: (arg0: string) => boolean, arg: string) => boolean
>func : (arg0: string) => boolean
>arg : string
return func(arg);
>func(arg) : boolean
>func : (arg0: string) => boolean
>arg : string
}

View File

@ -0,0 +1,20 @@
// @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: mod1.js
/**
* @typedef {function(string): boolean}
* MyType
*/
/**
* Tries to use a type whose name is on a different
* line than the typedef tag.
* @param {MyType} func The function to call.
* @param {string} arg The argument to call it with.
* @returns {boolean} The return.
*/
function callIt(func, arg) {
return func(arg);
}