Skip to content

Reflect Options keys in return types#49

Open
fan-tom wants to merge 1 commit intojackbearheart:masterfrom
fan-tom:improve_typings
Open

Reflect Options keys in return types#49
fan-tom wants to merge 1 commit intojackbearheart:masterfrom
fan-tom:improve_typings

Conversation

@fan-tom
Copy link
Copy Markdown

@fan-tom fan-tom commented Jan 27, 2020

Currently return types of functions are very imprecise. For example, if you call parseFrom({input: myEmail, oneResult: true}) it returns one value despite type is still (ParsedMailbox | ParsedGroup)[]. The same issue with simple option. After this PR is merged, that options, if they are statically known to have true value affect return type of all exported functions to correctly reflect return value shape.

@jackbearheart
Copy link
Copy Markdown
Owner

This PR makes me wonder if the library should have a major version bump that straightens out the return values. Perhaps instead of the options changing the type of the return value, there should be separate functions. I think that would be simpler both for TS users and non-TS users. It's inconvenient to change type signatures but it would be better in the long run. 🤔

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.

2 participants