How to fix this type error , even that i already define a String type to key parameter.
function checkIsExistObjectKeys(object: Object, key: String): Boolean { return key in object; } console.log( checkIsExistObjectKeys( { name: "john", lastName: "Francois", }, "name" ) );
The key parameter should be of type string, not String.
string
String
function checkIsExistObjectKeys(object: Object, key: string): boolean { return Object.keys(object).some(x => x === key); }