Closed
Description
lib Update Request
I think it would be nice for not null inference to work in compound expressions like expr1 || expr2
.
If you assign the expression to a local variable it works okay.
Configuration Check
My compilation target is ES2015
and my lib is the default
.
Missing / Incorrect Definition
Sample Code
I think it would be nice for not null inference to work in compound expressions like expr1 || expr2
.
interface MyInterace {
message: 'hola'
}
type MyType = MyInterace | null;
function retrieveMessage (read: MyInterace) {
return read.message
}
function run( error1: MyType, error2:MyType ) {
// Type error
return (error1 || error2) ? retrieveMessage(error1 || error2) : 'hola'
}
function run2( error1: MyType, error2:MyType ) {
const localError = error1 || error2;
// Works fine
return localError ? retrieveMessage(localError) : 'hola'
}