Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ajbogh opened this issue Feb 8, 2021 · 1 comment
Open

Comments

@ajbogh
Copy link
Contributor

ajbogh commented Feb 8, 2021

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 ajbogh changed the title Map types changed from 0.9.0 to 0.11.0 to become exact matches Map types changed from 0.9.0 to 0.11.0 to become exact width matches Feb 8, 2021
@ajbogh
Copy link
Contributor Author

ajbogh commented Feb 9, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant