Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ghost opened this issue Jun 20, 2017 · 2 comments
Closed

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

ghost opened this issue Jun 20, 2017 · 2 comments
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@ghost
Copy link

ghost commented Jun 20, 2017

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))

@ghost ghost mentioned this issue Jun 28, 2017
@ghost
Copy link
Author

ghost commented Jul 10, 2017

With --noImplicitAny true --strictNullChecks false, I would expect an un-annotated [] to fail -- and it does, but only inside another array, as in [[]].

const a = []; // OK?
const b = [[]]; // Error
const c = [].map(() => []); // OK?

@paleo
Copy link

paleo commented Feb 20, 2018

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[] = []

@mhegazy mhegazy added this to the TypeScript 2.9 milestone Apr 12, 2018
@mhegazy mhegazy modified the milestones: TypeScript 3.0, Future Jul 2, 2018
@sandersn sandersn removed their assignment Jan 7, 2020
@RyanCavanaugh RyanCavanaugh added Working as Intended The behavior described is the intended behavior; this is not a bug and removed Bug A bug in TypeScript labels Feb 24, 2020
@RyanCavanaugh RyanCavanaugh removed this from the Backlog milestone Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

4 participants