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

Adding type annotations via flow type-at-pos? #30

Open
meandmax opened this issue Jun 21, 2021 · 2 comments
Open

Adding type annotations via flow type-at-pos? #30

meandmax opened this issue Jun 21, 2021 · 2 comments

Comments

@meandmax
Copy link
Contributor

meandmax commented Jun 21, 2021

Interesting concept. Wondering if this could be something that is also interesting for flowts: https://github.com/Airtable/typescript-migration-codemod/blob/main/src/typescript/flow_type_at_pos.ts

This would add annotations, where flow knows the type so it would increase type coverage. Just bringing that up in case you are interested.

@zxbodya
Copy link
Owner

zxbodya commented Jun 21, 2021

Indeed that might be interesting, might be worth to experiment with.

However, I am a bit skeptical about how beneficial that would be - my feeling is that in most cases where annotations are missing - TypeScript can successfully infer them, and so adding more flow based types might only increase amount of fixes to be made manually…

Other thing in this direction, that might be more interesting to look into - codemod provided by flow team for "type first" type annotations - https://flow.org/en/docs/cli/annotate-exports/

Theoretically it should add type annotation are to be added only at module boundaries(which is generally what is preferred for typescript as well), and so - there should be not much noise from it, but noticeable improvement in type coverage. Yet to try using it…

@meyer
Copy link

meyer commented Jun 22, 2021

oh neat, i was about to write something that uses type-at-pos to augment flowts. it would be real handy for cleaning up the implicit anys that pop up during conversion.

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

3 participants