Open
Description
TypeScript Version: 2.9.1
Search Terms:
object spread getter
Code
const A = { a: 1 };
const X = { ...A, get x() { return this.a } };
const Y = { a: A.a, get x() { return this.a } };
console.log(X.x, Y.x)
Expected behavior:
1 1
Actual behavior:
undefined 1
The proposal says that get x()
should not be called (section Getters on the Object Initializer).
Executing the code in Chrome (66) console produces the expected behavior.
Playground Link:
link