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

Do not apply exactness to types containing indexers #191

Merged
merged 1 commit into from
Jul 23, 2022

Conversation

namuol
Copy link
Contributor

@namuol namuol commented Jul 22, 2022

I believe I have found an edge case affecting those using older versions of Flow (<0.126.0), which this PR aims to solve.

It's easiest to see what this PR does with some examples:

TypeScript input Before After
type Map = {
  [key: string]: string;
};
type Map = {
  [key: string]: string,
  ...
};

The ... here is ignored by Flow, so it can be removed

type Map = {
  [key: string]: string,
};
Same as above with --no-inexact
type Map = {|
  [key: string]: string,
|};

Using indexers in exact objects was unsupported in Flow up until v0.126.0.

type Map = {
  [key: string]: string,
};

Same as above; no exact syntax for types containing indexers.

An "exact" object with an indexer doesn't really make sense, since the purpose of the indexer is to allow you to provide arbitrary keys, so removing exactness from an object with an indexer should be a no-op in Flow >=0.126.0 and should fix unusable types for older Flow versions

Thank you so much to all the contributors! ❤️ flowgen is a fantastic tool!

@orta
Copy link
Collaborator

orta commented Jul 23, 2022

dang - 60 versions behind :P

Cool, this seems reasonable to me - thanks for the well described PR!

@orta orta merged commit 404c2ef into joarwilk:master Jul 23, 2022
@orta
Copy link
Collaborator

orta commented Jul 23, 2022

Shipped:

npm notice name:          flowgen                                 
npm notice version:       1.20.1                                  

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

Successfully merging this pull request may close these issues.

None yet

2 participants