Is it possible to combine user defined type guards in TypeScript?

Viewed 1506

Given

type Maybe<T> = T | undefined;

class Obj {
    jbo: Maybe<Jbo>;
}

, is it possible to define a function that given a o: Maybe<Obj> asserts the types of both o and o.jbo?

I'm thinking of something like:

function everythingIsDefined(o: Maybe<Obj>):o is Obj && o.jbo is Jbo {
    // checks in here
}
2 Answers
Related