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
[strict-boolean-expressions] Allow any
#754
Comments
We're not looking for exact 1:1 compatibility with tslint, because as a system that's grown and evolved over time, not every feature/flag is needed, nor are they necessarily a good idea.. IMO this is working as expected right now - you're passing a non-boolean value into a place that's expecting a boolean.
nope. it's too easy to accidentally fall into a place that has an
nope for the same reasons.
This could work, sure. We need to add some options to the rule anyways because it's very, very strict without any options. |
I respect that, but it can mean that someone who has relied on certain functionality will now have to stop using the rule as it would potentially flag thousands of new issues. (In this specific case, that doesn't apply to me, as I had not yet started using the equivalent TSLint rule.)
I don't know. That might be true for explicit i.e. const x;
if (x) {} // `x` is implicitly `any`, so it doesn't really have an explicitly-set type.
My point was that this would be flagged by
Agreed. |
It is, but there's no distinction in the compiler. It's either reported with type
Sure your specific case would be flagged by that case. But consider this case: // someModule.d.ts
export const untyped: any;
// myFile.ts
import { untyped } from 'someModule';
if (untyped) {} What happens here?
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type MyRecord = { foo: any, bar: number }
declare const x: MyRecord;
const y = x.foo; // typed as any
// @ts-ignore
const z = x.baz; // typed as any Which is why the default behaviour of blocking
Yeah I know - it means that it can take a little bit for these new rules to become adopted. Also it gives us the opportunity to merge options together. I.e. we might look and go "you'd never use flag X without flag Y, so lets add 1 options instead". |
@glen-84 This rule is about being explicit and ignoring |
This is about implicit In those cases, developers could benefit from |
This has been solved by #1631, which will be released in v3 |
Repro
Expected Result
No error (at least with an option).
Actual Result
Error:
Unexpected non-boolean in conditional.
Additional Info
TSLint seems to ignore
any
.Implementation choices:
any
always (should rather be handled by no implicit/explicit any)allowAny
, defaulting totrue
.allowAny
, defaulting tofalse
.Versions
@typescript-eslint/eslint-plugin
1.13.0
@typescript-eslint/parser
1.13.0
TypeScript
3.4.5
ESLint
6.1.0
node
10.16.0
npm
6.9.0
The text was updated successfully, but these errors were encountered: