'Extended interfaces with union type is throwing "property does not exist on type" error. How to fix this?
Solution 1:[1]
Looks like TypeScript is preventing me from potentially accessing variant on IChordShape, which wouldn't exist.
The following changes by using in solved the issue :
if("variant" in rawShape && rawShape["variant"] === "inversion"){}
This is to make sure that the property variant does exist before accessing it
OR
Amend IChordShape to include variant: string; and keep more specific type for variant in the extending interfaces so that accessing rawShape["variant"] doesn't error out.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Prabhu |



