Skip to content

This condition will always return 'false' since the types 'true' and 'false' have no overlap #29155

Closed
@txiaocao

Description

@txiaocao

**TypeScript Version: "typescript": "^3.2.2"

This is an asynchronous method that controls its pause externally, so it needs to be removed at the right time. However, an error warning was given to indicate that this method is not feasible.

  public async show() {
    this.showing = true;
    while (this.showing) {
      for (const frameKey in DogDto.EffectSaveInfo) {
        // [ts] This condition will always return 'false' since the types 'true' and 'false' have no overlap.
        if (this.showing === false) {
          this.container.removeAllChildren();
          break;
        }
        const frameInfo = DogDto.EffectSaveInfo[frameKey];
        const frameIndex = Number(frameKey);
        const frameBitmap = await BitmapUtils.getBitmap(DogDto.EffetcSaveImageList[frameIndex]);
        frameBitmap.x = -1 * frameInfo.origin.x;
        frameBitmap.y = -1 * frameInfo.origin.y;
        container.removeAllChildren();
        container.addChild(frameBitmap);
        await LarkDate.delay(frameInfo.delay);
      }
    }
  }
  public hide() {
    this.showing = false;
  }

usage

  public async showEffect() {
    this.effectSave.show();
    await LarkDate.delay(3 * 1000);
    this.effectSave.hide();
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Control FlowThe issue relates to control flow analysis

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions