-
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.
Fix getTypeFromJSDocVariadicType in callback tag (#43562)
* Fix getTypeFromJSDocVariadicType in @callback Variadics have never worked there, I think. * add test + fix lint * remove outdated comment
- Loading branch information
Showing
5 changed files
with
90 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//// [callbackTagVariadicType.js] | ||
/** | ||
* @callback Foo | ||
* @param {...string} args | ||
* @returns {number} | ||
*/ | ||
|
||
/** @type {Foo} */ | ||
export const x = () => 1 | ||
var res = x('a', 'b') | ||
|
||
|
||
//// [callbackTagVariadicType.js] | ||
"use strict"; | ||
/** | ||
* @callback Foo | ||
* @param {...string} args | ||
* @returns {number} | ||
*/ | ||
exports.__esModule = true; | ||
exports.x = void 0; | ||
/** @type {Foo} */ | ||
var x = function () { return 1; }; | ||
exports.x = x; | ||
var res = (0, exports.x)('a', 'b'); | ||
|
||
|
||
//// [callbackTagVariadicType.d.ts] | ||
/** | ||
* @callback Foo | ||
* @param {...string} args | ||
* @returns {number} | ||
*/ | ||
/** @type {Foo} */ | ||
export const x: Foo; | ||
export type Foo = (...args: string[]) => number; |
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,15 @@ | ||
=== tests/cases/conformance/jsdoc/callbackTagVariadicType.js === | ||
/** | ||
* @callback Foo | ||
* @param {...string} args | ||
* @returns {number} | ||
*/ | ||
|
||
/** @type {Foo} */ | ||
export const x = () => 1 | ||
>x : Symbol(x, Decl(callbackTagVariadicType.js, 7, 12)) | ||
|
||
var res = x('a', 'b') | ||
>res : Symbol(res, Decl(callbackTagVariadicType.js, 8, 3)) | ||
>x : Symbol(x, Decl(callbackTagVariadicType.js, 7, 12)) | ||
|
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,20 @@ | ||
=== tests/cases/conformance/jsdoc/callbackTagVariadicType.js === | ||
/** | ||
* @callback Foo | ||
* @param {...string} args | ||
* @returns {number} | ||
*/ | ||
|
||
/** @type {Foo} */ | ||
export const x = () => 1 | ||
>x : Foo | ||
>() => 1 : () => number | ||
>1 : 1 | ||
|
||
var res = x('a', 'b') | ||
>res : number | ||
>x('a', 'b') : number | ||
>x : Foo | ||
>'a' : "a" | ||
>'b' : "b" | ||
|
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,14 @@ | ||
// @declaration: true | ||
// @outDir: bin/ | ||
// @checkJs: true | ||
// @Filename: callbackTagVariadicType.js | ||
|
||
/** | ||
* @callback Foo | ||
* @param {...string} args | ||
* @returns {number} | ||
*/ | ||
|
||
/** @type {Foo} */ | ||
export const x = () => 1 | ||
var res = x('a', 'b') |