Skip to content

strictNullChecks and "This condition will always return..." #34770

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
lukaszprus opened this issue Oct 28, 2019 · 1 comment
Closed

strictNullChecks and "This condition will always return..." #34770

lukaszprus opened this issue Oct 28, 2019 · 1 comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@lukaszprus
Copy link

TypeScript Version: 3.6.3

Search Terms:

strictNullChecks

Code

const a = (x: number): number => {
  if (x === null) {
    console.log(1);
  }

  if (x === 'grhrt') {
    console.log(1);
  }

  return x;
};

a(null);

Expected behavior:

With strictNullChecks option I would expect an error in line 2 similar to the one in line 6. Something of the form "This condition will always return 'false'... "

Actual behavior:

No error in line 2

Playground Link:

https://www.typescriptlang.org/play/index.html?noImplicitAny=false&strictFunctionTypes=false&strictPropertyInitialization=false&strictBindCallApply=false&noImplicitThis=false&noImplicitReturns=false&alwaysStrict=false&esModuleInterop=false&target=2&ssl=13&ssc=9&pln=1&pc=1#code/MYewdgzgLgBAhjAvDAFADwFwzAVwLYBGApgE4CUWuhpSAfDAN4CwAUDDAJYBmqaSiyXABshZRq3btQkEEKIA6ISADmKAIxkA3BJgBfVju69+yAOTKSACxJRTY5m0nSIshUtUbtj-Sx0kiUDgkYDBoXrperHAowqKaQA

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Oct 28, 2019
@RyanCavanaugh
Copy link
Member

Working as intended. See #11920 for the suggestion to opt in to an error

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

2 participants