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

Updated types to infer output formats #903

Open
Balearica opened this issue Mar 16, 2024 · 0 comments
Open

Updated types to infer output formats #903

Balearica opened this issue Mar 16, 2024 · 0 comments

Comments

@Balearica
Copy link
Member

Output formats may be enabled or disabled using the output argument on worker.recognize. However, the types are currently not intelligent enough to figure out whether an output format is enabled or disabled.

For example, in the code below, img should have type string, however it instead has type string | null.

const res = await worker.recognize(imageDummy, {}, { imageColor: true });
const img = res.data.imageColor;

This is not a huge deal, as the types can be edited to either (1) hard-code the fact that img is non-null or (2) add a check in code for img being non-null, however both of these fixes are sub-optimal. Ideally, type inference would work automatically, and the type of img could be automatically inferred based on the input arguments.

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