thrift2flow icon indicating copy to clipboard operation
thrift2flow copied to clipboard

Map types changed from 0.9.0 to 0.11.0 to become exact width matches

Open ajbogh opened this issue 4 years ago • 1 comments

It seems as though there's a breaking change in thrift2flow 0.11.0 where maps become exact width maps in the js files:

3: optional map<string,string> myStringMap

Used to be this in 0.9.0

myStringMap?: ?{ [string]: string }

Is now this in 0.11.0

myStringMap?: ?{| [string]: string |}

This is a breaking change if flowtype was checking the types of assigned objects before. Afterward it produces this error:

Cannot assign Object.freeze(...) to pizza because property minSpend is missing in object type [1] but exists in object
literal [2] in property someVariable.myStringMap.

ajbogh avatar Feb 08 '21 18:02 ajbogh

I've discovered that if you upgrade to Flow 0.126.0 or higher then the error will disappear.

This is a breaking change for anybody running Flow 0.125.1 or lower, and should be a major version bump for thrift2flow instead of a minor version update. It's possible that nobody knew about the error, so perhaps there's a way to change the code to be compatible with old Flow versions, or delete the incompatible version from npm and republish as a major version with higher Flow version prerequisites.

Here's a tryflow example that allows you to switch the versions. On 0.125.1 it will error, but 0.126.0 it doesn't.

https://flow.org/try/#0PQKgBAAgZgNg9gdzCYAoALgTwA4FMwAiYAvGAN4A+qYYA2gM7oBOAlgHYDmAugFxiOtOqCgF8A3KlQBjOG0ZgAJgEY+RUgHkARgCtcU9ADooTXLgBeuABRkw6XIz4ByABa4Y8R2BEBKCTLnoigBMqiRgWrr6RibmVjZ2DmAubh4ANLb26CFJCHBMMAqePhJAA

ajbogh avatar Feb 09 '21 23:02 ajbogh