You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
generic type inference for boolean literals fails #19896
functiontest<T>(x: T,f: (y: T)=>void){returnx;}letz: false=false;test(z,x=>{z=x;});// ------------^// [ts]// Type 'boolean | undefined' is not assignable to type 'false | undefined'.// Type 'true' is not assignable to type 'false | undefined'.
typescript permits boolean literals as type declarators. this is particularly relevant in React development, since false means do not render anything, but true cannot be rendered.
Activity
patsissons commentedon Nov 10, 2017
I'll try and test this in@nextwhen i get a chance, just trying to get this issue posted for now.confirmed on
2.7.0-dev.20171109:Proculopsis commentedon Nov 18, 2017
// let z: false = false;
let z: boolean = false;
Isn't this a compiler bug, letting you use 'false' as a type rather than 'boolean'?
patsissons commentedon Nov 18, 2017
typescript permits boolean literals as type declarators. this is particularly relevant in React development, since
falsemeans do not render anything, buttruecannot be rendered.RyanCavanaugh commentedon Nov 20, 2017
Mohamed Hegazy (@mhegazy) what is the inferred suggestion here?
Qwertiy commentedon Jul 11, 2020
Seems working fine on 3.9.2.
jakebailey commentedon Jul 9, 2023
Just looking at old issues; this was fixed back by #27042.