- Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
Description
TypeScript Version: 3.7.2
Search Terms:
NonNullable this this[] this property nonnullable
Code
typeSomeType=string|undefinedclassTest{prop: SomeTypefunc1=(): this['prop']=>{returnthis.prop}func2=(): SomeType=>{returnthis.prop}func3=(): NonNullable<this['prop']>=>{returnthis.prop!}func4=(): NonNullable<SomeType>=>{returnthis.prop!}}Expected behavior:
This code compiles correctly, this['prop'] and SomeType point to the same type.
Actual behavior:
func3 is not happy with the return statement: Type 'string' is not assignable to type 'NonNullable<this["prop"]>'.
Playground Link:link
Related Issues: none
JoniJnm
Metadata
Metadata
Assignees
Labels
Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.