Object.values should not accept undefined or null #20550
Labels
Bug
A bug in TypeScript
Domain: lib.d.ts
The issue relates to the different libraries shipped with TypeScript
Fixed
A PR has been merged for this issue
Milestone
TypeScript Version: 2.7.0-dev.201xxxxx
Reproduced locally with
2.5.3
but it seems to still be the case in master. https://github.com/Microsoft/TypeScript/blob/master/src/lib/es2017.object.d.tsCode
Expected behaviour:
This should be a compile error, like
Object.keys(undefined)
is.The type signature for
Object.keys
isbut for
Object.values
andObject.entities
it is:Ideally it would be nice to have specialisations for if
o: string
as well, but at minimum it would be nice to at least replaceo: any
witho: {}
to catch the above error.Actual behaviour:
This compiles correctly and gives a runtime error.
The text was updated successfully, but these errors were encountered: