OpenedWindowState
type OpenedWindowState<R> = | { error: undefined; result: undefined; status: "idle";} | { error: undefined; result: undefined; status: "opening";} | { error: undefined; result: undefined; status: "connected";} | { error: undefined; result: R; status: "done";} | { error: WindowClosedError; result: undefined; status: "closed-early";} | { error: unknown; result: undefined; status: "error";};The flow’s state as a discriminated union, so status narrows result and
error for you. Three independent fields could not: result was R | undefined even in the ‘done’ branch, which is why reading it needed a
non-null assertion at every call site.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
R |
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ error: undefined; result: undefined; status: "idle";}Type Literal
Section titled “Type Literal”{ error: undefined; result: undefined; status: "opening";}Type Literal
Section titled “Type Literal”{ error: undefined; result: undefined; status: "connected";}Type Literal
Section titled “Type Literal”{ error: undefined; result: R; status: "done";}Type Literal
Section titled “Type Literal”{ error: WindowClosedError; result: undefined; status: "closed-early";}The child window went away before calling finish().
Type Literal
Section titled “Type Literal”{ error: unknown; result: undefined; status: "error";}The handshake timed out, the popup was blocked, or the factory threw.