joarwilk / flowgen

Generate flowtype definition files from TypeScript
Other
658 stars 78 forks source link

Add some type annotations replacing `any`, mostly in src/printers/ #181

Closed gnprice closed 2 years ago

gnprice commented 2 years ago

While exploring the codebase to develop changes, I found myself wanting to know what I could expect to be the actual types of various things that are currently annotated as any. Given what this project is about, probably anyone reading this needs no persuasion on that point. :slightly_smiling_face: So I figured I'd write down some results as type annotations and share them.

These changes are probably easiest to review commit by commit, rather than the whole diff together -- each commit is small and generally has an explanation of why the type is right. Of course one important check is just the fact that the type-checker still accepts the code; but given that there are any types elsewhere in the codebase, I also carefully looked at the call sites of functions (etc.) to confirm that the arguments being passed aren't themselves any, and instead have real types which I used to determine what type to write on the function parameter.

(Where the call sites do use any, I figure it'll be better to take care of those callers first. This PR contains a couple of chains like that, of annotating first a caller and then its callees.)

For some of these, note that RawNode is another name for any.

orta commented 2 years ago

Cool, yeah, looks good to me - nice work