Skip to content

any in array prevents type checking rest of array #38870

Closed
@danielzgtg

Description

@danielzgtg

TypeScript Version: 3.9.3

Search Terms: "any array", "any list", "any prevents"

Code

// Works properly
let x: number = 123;
let y: number[] = [
        123,
        x,
        true,
];
// Doesn't work properly
let x: any = 123;
let y: number[] = [
        123,
        x,
        true,
];

Expected behavior: For both code snippets to result in the same compile error.

Actual behavior: The second snippet compiles without any error. This is unsound.

Playground Link: First Second

Related Issues: No

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions