diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 30530f51ab400..62165bd78f7dd 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3421,6 +3421,7 @@ namespace ts { getWidenedType(type: Type): Type; /* @internal */ getPromisedTypeOfPromise(promise: Type, errorNode?: Node): Type | undefined; + /* @internal */ getAwaitedType(type: Type): Type | undefined; getReturnTypeOfSignature(signature: Signature): Type; /** diff --git a/src/services/codefixes/fixReturnTypeInAsyncFunction.ts b/src/services/codefixes/fixReturnTypeInAsyncFunction.ts index 0c0287beeffc5..39e2c1900f3c7 100644 --- a/src/services/codefixes/fixReturnTypeInAsyncFunction.ts +++ b/src/services/codefixes/fixReturnTypeInAsyncFunction.ts @@ -24,7 +24,11 @@ namespace ts.codefix { } const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info; const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, returnTypeNode, promisedTypeNode)); - return [createCodeFixAction(fixId, changes, [Diagnostics.Replace_0_with_Promise_1, checker.typeToString(returnType), checker.typeToString(promisedType)], fixId, Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions)]; + return [createCodeFixAction( + fixId, changes, + [Diagnostics.Replace_0_with_Promise_1, + checker.typeToString(returnType), checker.typeToString(promisedType)], + fixId, Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions)]; }, getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => { const info = getInfo(diag.file, context.program.getTypeChecker(), diag.start); diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 5ed6e72bb7335..22d6234d13d6b 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -2035,7 +2035,6 @@ declare namespace ts { getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; getWidenedType(type: Type): Type; - getAwaitedType(type: Type): Type | undefined; getReturnTypeOfSignature(signature: Signature): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 5328478fb3dec..4e4746560ed7c 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -2035,7 +2035,6 @@ declare namespace ts { getBaseTypes(type: InterfaceType): BaseType[]; getBaseTypeOfLiteralType(type: Type): Type; getWidenedType(type: Type): Type; - getAwaitedType(type: Type): Type | undefined; getReturnTypeOfSignature(signature: Signature): Type; getNullableType(type: Type, flags: TypeFlags): Type; getNonNullableType(type: Type): Type; diff --git a/tests/baselines/reference/asyncArrowFunction_allowJs.errors.txt b/tests/baselines/reference/asyncArrowFunction_allowJs.errors.txt index e006f1668c13b..2a33da31b95d6 100644 --- a/tests/baselines/reference/asyncArrowFunction_allowJs.errors.txt +++ b/tests/baselines/reference/asyncArrowFunction_allowJs.errors.txt @@ -1,7 +1,7 @@ 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 type. +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 type. Did you mean to write 'Promise'? 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 type. +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 type. Did you mean to write 'Promise'? 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' is not assignable to parameter of type '() => string'. Type 'Promise' is not assignable to type 'string'. @@ -17,7 +17,7 @@ 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 type. +!!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? const b = async () => 0 ~ !!! error TS2322: Type '0' is not assignable to type 'string'. @@ -25,7 +25,7 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(19,3): error TS2 // No error (bad) /** @type {function(): string} */ ~~~~~~ -!!! error TS1064: The return type of an async function or method must be the global Promise type. +!!! error TS1064: The return type of an async function or method must be the global Promise type. Did you mean to write 'Promise'? const c = async () => { return 0 ~~~~~~~~