Skip to content

Odd behavior with --noImplicitAny false --strictNullChecks true #16651

Closed

Description

Given this code:

const x = [];
x.push(1);
const y: string = x[0];

With various settings of --noImplicitAny and strictNullChecks, we get the following types for x on line 3:

--noImplicitAny false --noImplicitAny true
--strictNullChecks false any[] number[]
--strictNullChecks true never[] number[]

I would expect the lower-left corner to also be any[], not never[].
(Ref: #16218 (comment))

Activity

  1. paleo commented on Feb 20, 2018

    @paleo

    I would expect the lower-left corner to also be any[], not never[].

    Thank you.

    With the --strict true and --noImplicitAny false compiler options, the compiler forces us to sprinkle the code with unpleasant statements:

    const arr: any[] = []
    
  2. added
    Working as IntendedThe behavior described is the intended behavior; this is not a bug
    and removed
    BugA bug in TypeScript
    on Feb 24, 2020
  3. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions