Skip to content

Object spread incorrectly compiles getter #24799

Open
@dsehnal

Description

@dsehnal

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptES2018Relates to the ES2018 Spec

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions