You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enumKind{Square="square",Rectangle="rectangle"}typeShape=|{kind: Kind.Square;size: number;}|{kind: Kind.Rectangle;width: number;height: number;};functionarea(s: Shape){switch(s.kind){caseKind.Square: {letb=s.size*s.size;break;}default: {letb=s.width*s.height;break;}}}functionarea2(s: Shape){const{ kind }=s;switch(kind){caseKind.Square: {// [ts]// Property 'width' does not exist on type 'Shape'.// Property 'width' does not exist on type '{ kind: Kind.Square; size: number; }'.letb=s.size*s.size;break;}default: {// [ts]// Property 'width' does not exist on type 'Shape'.// Property 'width' does not exist on type '{ kind: Kind.Square; size: number; }'.letb=s.width*s.height;break;}}}
Expected behavior:
No error
Actual behavior:
test.ts(34,19): error TS2339: Property 'size' does not exist on type 'Shape'.
Property 'size' does not exist on type '{ kind: Kind.Rectangle; width: number; height: number; }'.
test.ts(34,28): error TS2339: Property 'size' does not exist on type 'Shape'.
Property 'size' does not exist on type '{ kind: Kind.Rectangle; width: number; height: number; }'.
test.ts(38,19): error TS2339: Property 'width' does not exist on type 'Shape'.
Property 'width' does not exist on type '{ kind: Kind.Square; size: number; }'.
test.ts(38,29): error TS2339: Property 'height' does not exist on type 'Shape'.
Property 'height' does not exist on type '{ kind: Kind.Square; size: number; }'.
The text was updated successfully, but these errors were encountered:
TypeScript Version: 3.1.0
Search Terms: destruct implicit type
Code
Expected behavior:
No error
Actual behavior:
The text was updated successfully, but these errors were encountered: