Skip to content

Use unknown instead of any in automatically generated definitions #1505

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

Open
guillaumebrunerie opened this issue Feb 26, 2023 · 4 comments
Open

Comments

@guillaumebrunerie
Copy link

From what I understand, this library uses an automated system to read the specs and extract the types from them. Occasionally the spec does not specify any type and so this library defaults to any (for instance see #1237 for structuredClone).

I'd like to suggest to modify the tool to use unknown instead by default (and never use any), to err on the side of type safety.

@saschanaz
Copy link
Contributor

Using unknown would be indeed more strict, but doing so also will break many many existing codes, so I'm not sure we can do this. This at least requires some kind of conditional compiling.

@guillaumebrunerie
Copy link
Author

guillaumebrunerie commented Mar 18, 2023

Is it possible to do it only for future APIs? Or would it automatically apply to existing APIs as well?

@saschanaz
Copy link
Contributor

saschanaz commented Mar 18, 2023

Is it possible to do it only for futurs APIs?

Technically possible but the generator will need to maintain a big list of 'old APIs'. And that will also break consistency.

@kraktus
Copy link

kraktus commented Oct 30, 2024

Bump, this goes against the very purpose of typing, and is many causing issues in real code, latest occurence lichess-org/lila#16296.

A way to specify it, a breaking change or an alternative lib would be welcome.

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