-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Bug Report
π Search Terms
Type widening, promise, generic type widening.
π Version & Regression Information
This is the behavior in every version I tried.
β― Playground Link
π» Code
type Cb3 = <Res extends string | Promise<string>>(cb: () => Res) => Res
const c: Cb3 = {} as any;
// this don't widen the type, type of t31 is "1"
const t31 = c(() => {
return '1';
});
// but here is the problem, type of t32 is Promise<string>
const t32 = c(async () => {
return '1';
});π Actual behavior
Type of t32 is Promise<string>
π Expected behavior
Type of t32 is Promise<"1">, by analogy with type of t31
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
In DiscussionNot yet reached consensusNot yet reached consensusSuggestionAn idea for TypeScriptAn idea for TypeScript