Repository: TypeScript
Issue: Asserts on `this` from a member function does not narrow `this`
Labels: Suggestion,In Discussion

# Bug Report



### 🔎 Search Terms
- assert type guard
- this type guard

possibly related to #43368

### 🕗 Version & Regression Information

Seems to effect all versions



- This is the behavior in every version I tried, and I reviewed the FAQ for entries about 
    - https://github.com/microsoft/TypeScript/wiki/FAQ#why-is-astring-assignable-to-anumber-for-interface-at--
    - https://github.com/microsoft/TypeScript/wiki/FAQ#why-doesnt-x-instanceof-foo-narrow-x-to-foo
    - https://github.com/microsoft/TypeScript/wiki/FAQ#why-doesnt-isfoox-narrow-x-to-foo-when-isfoo-is-a-type-guard

### ⏯ Playground Link

[Playground link with relevant code](https://www.typescriptlang.org/play?ts=4.2.3&ssl=72&ssc=2&pln=1&pc=1#code/PQKgBAygpgLgrgBzCYAoAxgGwIYGdeRzrpT4BKpcmMAPACoB8YA3qmGLkSfgFxgwAnOFDABefkKgBuNmHQB7AHa5BRGPIEAKBHABGmAJbowAN2yZhfOgEoWAX1kwAFgPkB3APKKAYtgMWBKE1rPjxcKAEYAmcDAljCYlJcCk5qeiZmB3ZYiC4k4L4YuIJcxPJKNMYWWXZA+AFFfidYgDpOMtwZdgcHDBx8MF9-OECUqlo6ABowAFEwKAAPGChFABMCGYFXAQzZdu5cPgAzc3CxMBPMcK65JRUhdHUtHX0jea2NPhnbTMcXdy8QwCQRCYDCESiTXi8VKBzGlV27HYzlcbihuBaEW2NyyYByeXwBXReJKBOSFQmiKRdRGjSKbTJONQvRgAE8ECIPByBNgYAYlPCJudFFATBFpnNFss1hsPgJzpttkxRLIAD4JOEU9JqwZ+YGC+gShgyVBHOCKR78xpuDQAawMigA5gBBfAQgDicGwAlW6U0gVSMD4XIivKtBsYoPBkQIAfGJI1SQjVIMRzAmgAhHHqAyOtZWEimqiwNmYJi5bIeqhQLM1pBYIhkGhUC2FMoYCWKcHuWGBVr7g7Hcr7GCCCGeXy+4GaAOnQwWzW6M1ik0RLFOCIUKbzZalKPwpEl7E6OyQQXO4GWiiAT49SMQbJgMB+KeEzunNgnVBVrJS2An2A469ooBqzo6EpyvODg1jMdbyGm67CE2LbVuAS4iAGHa6FAmDuGANoCLaBB4HiijSqs37IWaFqTo0ijeqiXgAAquNybLBOeAEAOp2oOYD0R8bh8UcrgALZgAgrGyKm6alrmBz5jUF7jC0ZgWCIAGwkm-aCIO87dPMVwiOetQUuW2z-s+QL3qBulOhBSqVi2vTUbujTRjAJ4cp63qrBxLbsNxvFOvxDHuMJYlgK6B4dl5Ig+T6gw7rRYCyAR9pOtFHpej6-oUtYv5mWpSGaWStkCHpzktq5KUCaiR64HFCV+YpllgDxhF8XV4UhSJ8jibo8jyJgUCfmAcVgM1YAALJQKJ2Hyt4yVWqlhYyXll74h0wQ-EpcnFRpz5aeU05gfpYB2IZZwmcpOZYhobXWaMOkVfZsyQU5vQtkAA)

### 💻 Code


```ts
/* Setup */
class SuccessResult<T> {
  success: true = true;
  constructor(public value: T) {}
  throwOnFailure(): asserts this is SuccessResult<T> {}
  isSuccess(): this is SuccessResult<T> {
    return this.success;
  }
}

class FailureResult<T, E extends Error> {
  success: false = false;
  constructor(public error: E) {}
  throwOnFailure(): asserts this is SuccessResult<T> {
    throw this.error;
  }
  isSuccess(): this is SuccessResult<T> {
    return this.success;
  }
}

type OperationResult<T = never, E extends Error = Error> =
  | SuccessResult<T>
  | FailureResult<T, E>;

function workingAssertGuard<T>(result: OperationResult<T>): asserts result is SuccessResult<T> {
  if (!result.success){
    throw result.error
  }
}
/* End Setup */



const result: OperationResult<string> = {} as OperationResult<string>

/* This is the issue */
function assertThisType(){
  result.throwOnFailure()
  // type is unchanged
  result // OperationResult<string, Error>
}
/* End of issue */


/* The rest below works as intended */
function narrowOnProperty(){
  // Working narrowing from prop
  if (result.success){
    result.value // SuccessResult<string>
  } else {
    result.error // FailureResult<string, Error>
  }

}

function assertTypeGuard(){

  // Working narrowing from Assert Type Guard Function 
  workingAssertGuard(result)
  result.value // SuccessResult<string>

}

function narrowThisTypeGuard(){
 // Working narrowing from boolean Type Guard Member Function 
    if (result.isSuccess()) {
    result.value // SuccessResult<string>
  } else {
    result.error // FailureResult<string, Error>
  }
}
```

### 🙁 Actual behavior
Asserts on `this` from a member function does not narrow `this`

### 🙂 Expected behavior

Asserts on `this` from a member function does narrow `this`