-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
Description
TypeScript Version: 3.3.0-dev.201xxxxx
Search Terms: true boolean generic function extends default
Code
const fn = <T extends boolean>(flag: T | false = false) => flag
fn({} as boolean)
// The only workaround?
fn<boolean>({} as boolean)Expected behavior:
Expected fn<boolean>(flag?: boolean) to be inferred
Actual behavior:
Instead got fn<true>(flag?: boolean) as the inferred type.
The issue stems from T | false, which is required for = false to work.
Playground Link: Click here
Related Issues: Possibly #28154
malwilley, tonivj5, GregOnNet, aFcFzF, roydukkey and 2 more
Metadata
Metadata
Assignees
Labels
Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionRelated to type inference performed during signature resolution or `infer` type resolutionNeeds ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript