mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
fix(37242): add reference to return type for JSDocFunctionType (#37911)
This commit is contained in:
@@ -769,7 +769,7 @@ namespace ts {
|
||||
const sig = find(type.members, isCallSignatureDeclaration);
|
||||
return sig && sig.type;
|
||||
}
|
||||
if (isFunctionTypeNode(type)) {
|
||||
if (isFunctionTypeNode(type) || isJSDocFunctionType(type)) {
|
||||
return type.type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(3,17): error TS2322: Type '0' is not assignable to type 'string'.
|
||||
tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(6,24): error TS1064: The return type of an async function or method must be the global Promise<T> type.
|
||||
tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(7,23): error TS2322: Type '0' is not assignable to type 'string'.
|
||||
tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(10,24): error TS1064: The return type of an async function or method must be the global Promise<T> type.
|
||||
tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(12,2): error TS2322: Type '0' is not assignable to type 'string'.
|
||||
tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(19,3): error TS2345: Argument of type '() => Promise<number>' is not assignable to parameter of type '() => string'.
|
||||
Type 'Promise<number>' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/async/es2017/asyncArrowFunction/file.js (4 errors) ====
|
||||
==== tests/cases/conformance/async/es2017/asyncArrowFunction/file.js (6 errors) ====
|
||||
// Error (good)
|
||||
/** @type {function(): string} */
|
||||
const a = () => 0
|
||||
@@ -14,12 +16,16 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(19,3): error TS2
|
||||
|
||||
// Error (good)
|
||||
/** @type {function(): string} */
|
||||
~~~~~~
|
||||
!!! error TS1064: The return type of an async function or method must be the global Promise<T> type.
|
||||
const b = async () => 0
|
||||
~
|
||||
!!! error TS2322: Type '0' is not assignable to type 'string'.
|
||||
|
||||
// No error (bad)
|
||||
/** @type {function(): string} */
|
||||
~~~~~~
|
||||
!!! error TS1064: The return type of an async function or method must be the global Promise<T> type.
|
||||
const c = async () => {
|
||||
return 0
|
||||
~~~~~~~~
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/a.js(1,24): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
|
||||
|
||||
==== /a.js (1 errors) ====
|
||||
/** @type {function(): number} */
|
||||
~~~~~~
|
||||
!!! error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value.
|
||||
function f() {}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
=== /a.js ===
|
||||
/** @type {function(): number} */
|
||||
function f() {}
|
||||
>f : Symbol(f, Decl(a.js, 0, 0))
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
=== /a.js ===
|
||||
/** @type {function(): number} */
|
||||
function f() {}
|
||||
>f : () => number
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @noEmit: true
|
||||
// @strict: true
|
||||
|
||||
// @Filename: /a.js
|
||||
/** @type {function(): number} */
|
||||
function f() {}
|
||||
Reference in New Issue
Block a user