Skip to content

Commit ba02f43

Browse files
committed
Make getAwaitedType private
Also, fix an additional baseline change and break up huge line.
1 parent 0503da2 commit ba02f43

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

src/compiler/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3421,6 +3421,7 @@ namespace ts {
34213421
getWidenedType(type: Type): Type;
34223422
/* @internal */
34233423
getPromisedTypeOfPromise(promise: Type, errorNode?: Node): Type | undefined;
3424+
/* @internal */
34243425
getAwaitedType(type: Type): Type | undefined;
34253426
getReturnTypeOfSignature(signature: Signature): Type;
34263427
/**

src/services/codefixes/fixReturnTypeInAsyncFunction.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ namespace ts.codefix {
2424
}
2525
const { returnTypeNode, returnType, promisedTypeNode, promisedType } = info;
2626
const changes = textChanges.ChangeTracker.with(context, t => doChange(t, sourceFile, returnTypeNode, promisedTypeNode));
27-
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)];
27+
return [createCodeFixAction(
28+
fixId, changes,
29+
[Diagnostics.Replace_0_with_Promise_1,
30+
checker.typeToString(returnType), checker.typeToString(promisedType)],
31+
fixId, Diagnostics.Fix_all_incorrect_return_type_of_an_async_functions)];
2832
},
2933
getAllCodeActions: context => codeFixAll(context, errorCodes, (changes, diag) => {
3034
const info = getInfo(diag.file, context.program.getTypeChecker(), diag.start);

tests/baselines/reference/api/tsserverlibrary.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,6 @@ declare namespace ts {
20352035
getBaseTypes(type: InterfaceType): BaseType[];
20362036
getBaseTypeOfLiteralType(type: Type): Type;
20372037
getWidenedType(type: Type): Type;
2038-
getAwaitedType(type: Type): Type | undefined;
20392038
getReturnTypeOfSignature(signature: Signature): Type;
20402039
getNullableType(type: Type, flags: TypeFlags): Type;
20412040
getNonNullableType(type: Type): Type;

tests/baselines/reference/api/typescript.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,6 @@ declare namespace ts {
20352035
getBaseTypes(type: InterfaceType): BaseType[];
20362036
getBaseTypeOfLiteralType(type: Type): Type;
20372037
getWidenedType(type: Type): Type;
2038-
getAwaitedType(type: Type): Type | undefined;
20392038
getReturnTypeOfSignature(signature: Signature): Type;
20402039
getNullableType(type: Type, flags: TypeFlags): Type;
20412040
getNonNullableType(type: Type): Type;

tests/baselines/reference/asyncArrowFunction_allowJs.errors.txt

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(3,17): error TS2322: Type '0' is not assignable to type 'string'.
2-
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.
2+
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. Did you mean to write 'Promise<string>'?
33
tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(7,23): error TS2322: Type '0' is not assignable to type 'string'.
4-
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.
4+
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. Did you mean to write 'Promise<string>'?
55
tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(12,2): error TS2322: Type '0' is not assignable to type 'string'.
66
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'.
77
Type 'Promise<number>' is not assignable to type 'string'.
@@ -17,15 +17,15 @@ tests/cases/conformance/async/es2017/asyncArrowFunction/file.js(19,3): error TS2
1717
// Error (good)
1818
/** @type {function(): string} */
1919
~~~~~~
20-
!!! error TS1064: The return type of an async function or method must be the global Promise<T> type.
20+
!!! error TS1064: The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<string>'?
2121
const b = async () => 0
2222
~
2323
!!! error TS2322: Type '0' is not assignable to type 'string'.
2424

2525
// No error (bad)
2626
/** @type {function(): string} */
2727
~~~~~~
28-
!!! error TS1064: The return type of an async function or method must be the global Promise<T> type.
28+
!!! error TS1064: The return type of an async function or method must be the global Promise<T> type. Did you mean to write 'Promise<string>'?
2929
const c = async () => {
3030
return 0
3131
~~~~~~~~

0 commit comments

Comments
 (0)