Skip to content

Avoid array element extraction by index to avoid typecheck verification #1117

Description

@carlosthe19916

Some parts of the code might have:

const elem = array[index];
console.log(elem.field);

Which is dangerous because array[index] assumes elem is not null.

doing:

const elem = array[index] ?? null;
console.log(elem.field);

is also wrong because typescript won't assign "null" to elem's type

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-kindIndicates an issue or PR lacks a `kind/foo` label and requires one.needs-priorityIndicates an issue or PR lacks a `priority/foo` label and requires one.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.

    Type

    No type

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions