Skip to content

Optional Chaining doesn't work for Out-of-range array indexes #540

Open
@8BitJonny

Description

@8BitJonny

What

Using the Playground with the newest version 1.16 I expected Posts[10]?.Title to result in undefined whereas it throws

reflect: slice index out of range (3:6)
 | Posts[10]?.Title
 | .....^

Just like in JS [][1]?.a also works and yields null/undefined making things like [][1]?.a ?? 42 work where as Posts[10]?.Title ?? "default" does not work currently in with this library.
Or is this expected/deliberate?

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