is-what icon indicating copy to clipboard operation
is-what copied to clipboard

Use `unknown` instead of `any`

Open mesqueeb opened this issue 4 years ago • 2 comments

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 avatar Sep 01 '20 23:09 mesqueeb

the proposal comes from: image

mesqueeb avatar Sep 02 '20 00:09 mesqueeb

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>

casr avatar Nov 16 '20 15:11 casr

will land in v5

mesqueeb avatar May 24 '24 01:05 mesqueeb