-
Notifications
You must be signed in to change notification settings - Fork 715
Closed
Labels
Domain: Type CheckingRelated to type checking, grammar checkingRelated to type checking, grammar checkingType OrderingAn issue related to ordering of typesAn issue related to ordering of types
Description
Steps to reproduce
function validate() {
if(Math.random() > 0.5) {
return utilValidate();
}
return { valid: true };
};
declare function utilValidate(): {
valid: boolean;
msg?: undefined;
} | {
valid: boolean;
msg: string;
}
validate().msg; // Error in TSGO
Behavior with typescript@5.8
The return type of validate
is { valid: boolean; msg?: undefined; }
and validate().msg
has no error
Behavior with tsgo
validate().msg
raises the error: Property 'msg' does not exist on type '{ valid: boolean; }'.
suggesting the return type of validate
is { valid: boolean; }
. If utilValidate
is defined before validate
there is no error
Maybe related to #1738
Metadata
Metadata
Assignees
Labels
Domain: Type CheckingRelated to type checking, grammar checkingRelated to type checking, grammar checkingType OrderingAn issue related to ordering of typesAn issue related to ordering of types