// @flow // https://flow.org/try/#0PTAEAEDMBsHsHcBQiAuBPADgU1AUQHYCuAtgIIDGKAlrPqALygDkAhk6AD7MBG7XT5JgG5k6bKACS+AG4sATlRb4UFarQagA3h0ShQxLCgAWsACYAuPETKUa+ADSIOAXxGpMOAMKxZCpStt1Rm1dUABqA2MzSwISVTtHFzdIQnxAulNYKV9FZQAVIyp8AHMAChZ0y2z5XIC1fABKLWdEFLT60EzvHP8CorKK+stumv942ibNFtEPUDyPAHluACsNbX1DEwtmNk5XRHJaAGcUUGN+y3nsJdXgjajt1nZ9xEzqv3zCktLzkoaRLo+Uaffo-L7Ff6IIA type EnumAction = 'a' | 'b' | 'c'; type InvariantAction = {| method: EnumAction, |}; type CovariantAction = {| +method: EnumAction, |}; function doInvariantThing(action: InvariantAction) {} function doCovariantThing(action: CovariantAction) {} type TypeObj = {| method: 'a' |}; const thing: TypeObj = { method: 'a' }; doInvariantThing(thing); doCovariantThing(thing); // 20: doInvariantThing(thing); // ^ Cannot call `doInvariantThing` with `thing` bound to `action` because string literal `a` [1] is incompatible with string literal `b` [2] in property `method`. [incompatible-call] // References: // 17: type TypeObj = {| method: 'a' |}; // ^ [1] // 6: method: EnumAction, // ^ [2] // 20: doInvariantThing(thing); // ^ Cannot call `doInvariantThing` with `thing` bound to `action` because string literal `a` [1] is incompatible with string literal `c` [2] in property `method`. [incompatible-call] // References: // 17: type TypeObj = {| method: 'a' |}; // ^ [1] // 6: method: EnumAction, // ^ [2]