// @flow

type A<T> = { readonly $$type: 1, value: T } | { readonly $$type: 2, value: T };
type B<T> = A<T>;
declare opaque type O<T>;
type C<T> = B<T> | O<T>;

declare function isB<T>(compute: C<T>): compute is B<T>;

function test1(value: C<unknown>): void {
  if (isB(value)) {
    const _1 = value as B<unknown>;
    const _2: B<unknown> = value;
  }
}

function test2() {
    type StringC = C<string>;
    type StringB = B<string>;
    function b(value: StringC) {
        if (isB(value)) {
            const _1 = value as StringB;
            const _2: StringB = value;
        }
    }
}
