Closed
Description
TypeScript Version: 3.8.0-dev.20191231
Search Terms:
Code
class C {
#prop = 1;
method(other: C) {
const obj = { ...other };
obj.#prop; // expected error, got no error
const { ...rest } = other;
rest.#prop; // expected error, got error
}
}
Expected behavior:
Object spread should remove private named properties from the spreaded object type.
Actual behavior:
Private named properties are preserved on the spreaded type, accessing the property is not a type error. This causes a runtime error.
Note that object rest already works as expected.