-
Notifications
You must be signed in to change notification settings - Fork 12.8k
This condition will always return 'false' since the types 'true' and 'false' have no overlap #29155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Looks like control flow needs to be more pessimistic around |
Temporarily changed to recursive writing :) public async show() {
this.showing = true;
const container = this.container;
const frame = DogDto.EffetcSaveImageList[0];
const frameInfo = DogDto.EffectSaveInfo[0];
const bitmap = await BitmapUtils.getBitmap(frame);
bitmap.x = -1 * frameInfo.origin.x;
bitmap.y = -1 * frameInfo.origin.y;
container.addChild(bitmap);
await this.play();
}
public hide() {
this.showing = false;
}
private async play() {
const container = this.container;
for (const frameKey in DogDto.EffectSaveInfo) {
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);
if (this.showing === false) {
this.container.removeAllChildren();
break;
}
await LarkDate.delay(frameInfo.delay);
}
if (this.showing === true) {
await this.play();
}
} |
This is basically the same as calling a function, method or callback that could modify a narrowed variable. There should be plenty of duplicate issues, IIRC there was at least one regarding The proposed solution was using a method to retrieve the value instead of accessing the property directly. |
yes, it work ... class Test{
private status = false;
public async test(){
while(this.status){
if(this.getStatus() === false){
break;
}
}
}
private getStatus(){
return this.status;
}
} |
Why isn't this the correct answer? I understand the workaround, but it doesn't seem like it should be necessary. Not only does narrowing across |
**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.
usage
The text was updated successfully, but these errors were encountered: