Skip to content

Class optional member should not be initialized to undefined #25412

@lantua

Description

@lantua

What version of Bun is running?

1.3.4+5eb2145b3

What platform is your computer?

Darwin 25.1.0 arm64 arm

What steps can reproduce the bug?

This TS snippet creates a class with optional member, and check if the member exists with in.

class X { val?: number }
console.log("val" in new X())

What is the expected behavior?

false is printed to match TS behaviour.

What do you see instead?

true is printed.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions