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

Use unknown instead of any #12

Closed
mesqueeb opened this issue Sep 1, 2020 · 3 comments
Closed

Use unknown instead of any #12

mesqueeb opened this issue Sep 1, 2020 · 3 comments
Labels
Milestone

Comments

@mesqueeb
Copy link
Owner

mesqueeb commented Sep 1, 2020

CURRENTLY

We currently use any a lot like. Eg.:

image

This currently makes stuff like this possible without error:

image

PROPOSAL

When the user passes an array with "any" we could also convert the outcome to "unknown" instead like so:

image

Which will result in throwing errors because the type was converted from any to unknown:

image

As long as the array type is not any[] it will keep the array type as is:

image

@laquasicinque thoughts?

@mesqueeb
Copy link
Owner Author

mesqueeb commented Sep 2, 2020

the proposal comes from:
image

@casr
Copy link

casr commented Nov 16, 2020

On a related note, you may wish to define an object like:

// like in TS library files
Record<keyof any, unknown>

// or verbosely without the any
Record<string | number | symbol, unknown>

@jcbhmr jcbhmr changed the title deprecate any for unknown? Use unknown instead of `any Jun 3, 2023
@jcbhmr jcbhmr changed the title Use unknown instead of `any Use unknown instead of any Jun 3, 2023
@jcbhmr jcbhmr added this to the v5 milestone Jun 3, 2023
@mesqueeb
Copy link
Owner Author

will land in v5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants