mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-24 04:30:53 -06:00
Ignore newline and asterisk when parsing JSDoc typedef (#26775)
This commit is contained in:
parent
038f665171
commit
20a2b0cade
@ -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;
|
||||
|
||||
23
tests/baselines/reference/typedefTagWrapping.symbols
Normal file
23
tests/baselines/reference/typedefTagWrapping.symbols
Normal 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))
|
||||
}
|
||||
|
||||
24
tests/baselines/reference/typedefTagWrapping.types
Normal file
24
tests/baselines/reference/typedefTagWrapping.types
Normal 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
|
||||
}
|
||||
|
||||
20
tests/cases/conformance/jsdoc/typedefTagWrapping.ts
Normal file
20
tests/cases/conformance/jsdoc/typedefTagWrapping.ts
Normal 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);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user