Unlisted property narrowing with the in operator

Changes in new versions / TypeScript 4.9

// *** before: ***
function readPackageName(context: object) {
    if ("packageJSON" in context) {
        // context.packageJSON; // <-Error: type object has no properties at all
    }
}

// *** in version 4.9: ***
function readPackageNameChecked(context: object) {
    if ("packageJSON" in context) {
        console.log(context.packageJSON); // OK: context is narrowed to {
        //packageJSON: unknown }
    }
}