-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip asterisks after newline when parsing JSDoc types (#26528)
* Skip asterisks after newline when parsing JSDoc types * Single boolean expression * Test for parsing and printing multiline function signatures with *
- Loading branch information
Showing
8 changed files
with
641 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
tests/baselines/reference/typedefTagWrapping.errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
tests/cases/conformance/jsdoc/mod7.js(5,7): error TS1110: Type expected. | ||
tests/cases/conformance/jsdoc/mod7.js(8,4): error TS1110: Type expected. | ||
|
||
|
||
==== tests/cases/conformance/jsdoc/mod1.js (0 errors) ==== | ||
/** | ||
* @typedef {function(string): boolean} | ||
* Type1 | ||
*/ | ||
|
||
/** | ||
* Tries to use a type whose name is on a different | ||
* line than the typedef tag. | ||
* @param {Type1} 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); | ||
} | ||
|
||
==== tests/cases/conformance/jsdoc/mod2.js (0 errors) ==== | ||
/** | ||
* @typedef {{ | ||
* num: number, | ||
* str: string, | ||
* boo: boolean | ||
* }} Type2 | ||
*/ | ||
|
||
/** | ||
* Makes use of a type with a multiline type expression. | ||
* @param {Type2} obj The object. | ||
* @returns {string|number} The return. | ||
*/ | ||
function check(obj) { | ||
return obj.boo ? obj.num : obj.str; | ||
} | ||
|
||
==== tests/cases/conformance/jsdoc/mod3.js (0 errors) ==== | ||
/** | ||
* A function whose signature is very long. | ||
* | ||
* @typedef {function(boolean, string, number): | ||
* (string|number)} StringOrNumber1 | ||
*/ | ||
|
||
/** | ||
* Makes use of a function type with a long signature. | ||
* @param {StringOrNumber1} func The function. | ||
* @param {boolean} bool The condition. | ||
* @param {string} str The string. | ||
* @param {number} num The number. | ||
* @returns {string|number} The return. | ||
*/ | ||
function use1(func, bool, str, num) { | ||
return func(bool, str, num) | ||
} | ||
|
||
==== tests/cases/conformance/jsdoc/mod4.js (0 errors) ==== | ||
/** | ||
* A function whose signature is very long. | ||
* | ||
* @typedef {function(boolean, string, | ||
* number): | ||
* (string|number)} StringOrNumber2 | ||
*/ | ||
|
||
/** | ||
* Makes use of a function type with a long signature. | ||
* @param {StringOrNumber2} func The function. | ||
* @param {boolean} bool The condition. | ||
* @param {string} str The string. | ||
* @param {number} num The number. | ||
* @returns {string|number} The return. | ||
*/ | ||
function use2(func, bool, str, num) { | ||
return func(bool, str, num) | ||
} | ||
|
||
==== tests/cases/conformance/jsdoc/mod5.js (0 errors) ==== | ||
/** | ||
* @typedef {{ | ||
* num: | ||
* number, | ||
* str: | ||
* string, | ||
* boo: | ||
* boolean | ||
* }} Type5 | ||
*/ | ||
|
||
/** | ||
* Makes use of a type with a multiline type expression. | ||
* @param {Type5} obj The object. | ||
* @returns {string|number} The return. | ||
*/ | ||
function check5(obj) { | ||
return obj.boo ? obj.num : obj.str; | ||
} | ||
|
||
==== tests/cases/conformance/jsdoc/mod6.js (0 errors) ==== | ||
/** | ||
* @typedef {{ | ||
* foo: | ||
* *, | ||
* bar: | ||
* * | ||
* }} Type6 | ||
*/ | ||
|
||
/** | ||
* Makes use of a type with a multiline type expression. | ||
* @param {Type6} obj The object. | ||
* @returns {*} The return. | ||
*/ | ||
function check6(obj) { | ||
return obj.foo; | ||
} | ||
|
||
|
||
==== tests/cases/conformance/jsdoc/mod7.js (2 errors) ==== | ||
/** | ||
Multiline type expressions in comments without leading * are not supported. | ||
@typedef {{ | ||
foo: | ||
*, | ||
~ | ||
!!! error TS1110: Type expected. | ||
bar: | ||
* | ||
}} Type7 | ||
~ | ||
!!! error TS1110: Type expected. | ||
*/ | ||
|
Oops, something went wrong.