You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reflect.ownKeys has overly wide type definition #34626
Reflect.ownKeys has a return type definition of PropertyKey[] which is defined as declare type PropertyKey = string | number | symbol; but the method of ownKeys only returns (string | symbol)[].
To be fair, the type is not invalid, it’s just overly wide. The set of all strings is contained within the set of all strings and numbers, after all. Likewise if I have a function that always returns either “foo” or “bar” I can still claim it returns string despite not covering the entire set of possible strings.
Of course this is splitting hairs, but since you put “invalid” in the issue title I had to point it out 😉
Activity
fatcerberus commentedon Oct 21, 2019
To be fair, the type is not invalid, it’s just overly wide. The set of all strings is contained within the set of all strings and numbers, after all. Likewise if I have a function that always returns either “foo” or “bar” I can still claim it returns
stringdespite not covering the entire set of possible strings.Of course this is splitting hairs, but since you put “invalid” in the issue title I had to point it out 😉
[-]Reflect.ownKeys has invalid type definition[/-][+]Reflect.ownKeys has overly wide type definition[/+]ExE-Boss commentedon Dec 16, 2020
I’m fixing this in #41987.