mesqueeb / is-what

JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.
https://mesqueeb.github.io/is-what/
MIT License
169 stars 18 forks source link

Use `unknown` instead of `any` #12

Closed mesqueeb closed 1 month ago

mesqueeb commented 3 years ago

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 commented 3 years ago

the proposal comes from:

image
casr commented 3 years ago

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>
mesqueeb commented 1 month ago

will land in v5