// @target: es2015
// @strict: true
// @noEmit: true

// https://github.com/microsoft/TypeScript/issues/61784

type Test = TestA | TestB;

interface TestA {
  type: 'a';
  name: string;
}

interface TestB {
  type: 'b';
  value: number;
}

function _tcb1(this: { test: Test }) {
  // TS generated by Angular's Type Check block
  const _t1 = (((((this).test)).type));
  if (_t1 === "a") {
    (((((this).test)).name));
  }

  // Same as above, without the parenthesis
  const _t2 = this.test.type;
  if (_t2 === "a") {
    (((((this).test)).name));
  }

  // Same as above without parenthesis at both places
  const testType = this.test.type;
  if (testType === "a") {
    this.test.name;
  }
}

function _tcb2(this: { test: Test }) {
  // TS generated by Angular's Type Check block
  const _t1 = (((((this).test)).type));
  if ("a" === _t1) {
    (((((this).test)).name));
  }

  // Same as above, without the parenthesis
  const _t2 = this.test.type;
  if ("a" === _t2) {
    (((((this).test)).name));
  }

  // Same as above without parenthesis at both places
  const testType = this.test.type;
  if ("a" === testType) {
    this.test.name;
  }
}

function _tcb3(this: { test: Test }) {
  const { type: _t1 } = (((((this).test))));
  if (_t1 === "a") {
    (((((this).test)).name));
  }

  // Same as above, without the parenthesis
  const { type: _t2 } = this.test;
  if (_t2 === "a") {
    (((((this).test)).name));
  }

  // Same as above without parenthesis at both places
  const { type: testType } = this.test;
  if (testType === "a") {
    this.test.name;
  }
}

function _tcb4(this: { test: Test }) {
  const { type: _t1 } = (((((this).test))));
  if ("a" === _t1) {
    (((((this).test)).name));
  }

  // Same as above, without the parenthesis
  const { type: _t2 } = this.test;
  if ("a" === _t2) {
    (((((this).test)).name));
  }

  // Same as above without parenthesis at both places
  const { type: testType } = this.test;
  if ("a" === testType) {
    this.test.name;
  }
}

export {};
