We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
TypeScript Version: 3.9.2
Search Terms: false logical conjunction null
Expected behavior: Both statements should be valid
Actual behavior: One statement causes a typescript error
Code
const str: string | null = Math.random() > 0.5 ? "Hello World" : null; const isfalse = false; false && str && console.log(str.length) // Object (str) is possibly 'null'. isfalse && str && console.log(str.length) // Valid
"use strict"; const str = Math.random() > 0.5 ? "Hello World" : null; const isfalse = false; false && str && console.log(str.length); isfalse && str && console.log(str.length);
{ "compilerOptions": { "noImplicitAny": true, "strictNullChecks": true, "strictFunctionTypes": true, "strictPropertyInitialization": true, "strictBindCallApply": true, "noImplicitThis": true, "noImplicitReturns": true, "alwaysStrict": true, "esModuleInterop": true, "declaration": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "moduleResolution": 2, "target": "ES2017", "jsx": "React", "module": "ESNext" } }
Playground Link: Provided
Not the worst bug in the world and not very relevant for production scenarios, but interesting nonetheless.
The text was updated successfully, but these errors were encountered:
Duplicate #26914
Sorry, something went wrong.
No branches or pull requests
TypeScript Version: 3.9.2
Search Terms: false logical conjunction null
Expected behavior: Both statements should be valid
Actual behavior: One statement causes a typescript error
Code
Output
Compiler Options
Playground Link: Provided
Not the worst bug in the world and not very relevant for production scenarios, but interesting nonetheless.
The text was updated successfully, but these errors were encountered: