Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
fix(eslint-plugin): [prefer-nullish-coalescing] treat any/unknown as non-nullable#8262
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -10,8 +10,8 @@ import { | ||
| getTypeFlags, | ||
| isLogicalOrOperator, | ||
| isNodeEqual, | ||
| isNullLiteral, | ||
| isTypeFlagSet, | ||
| isUndefinedIdentifier, | ||
| nullThrows, | ||
| NullThrowsReasons, | ||
| @@ -309,7 +309,7 @@ export default createRule<Options, MessageIds>({ | ||
| ): void { | ||
| const tsNode = parserServices.esTreeNodeToTSNodeMap.get(node); | ||
| const type = checker.getTypeAtLocation(tsNode.left); | ||
| if (!isTypeFlagSet(type, ts.TypeFlags.Null | ts.TypeFlags.Undefined)) { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. @Josh-Cena threading#8262 (comment):
Hmm, good question. I think if the type is explicitly not known then it'd be risky to suggest making any concrete changes to its handling. I'd be in support of this as an opt-in in for v6 andmaybe an opt-out for v7. | ||
| return; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -222,6 +222,21 @@ x || y; | ||
| `, | ||
| options: [{ ignorePrimitives: true }], | ||
| })), | ||
| ` | ||
| declare const x: any; | ||
| declare const y: number; | ||
| x || y; | ||
| `, | ||
| ` | ||
| declare const x: unknown; | ||
| declare const y: number; | ||
| x || y; | ||
| `, | ||
| ` | ||
| declare const x: never; | ||
| declare const y: number; | ||
| x || y; | ||
| `, | ||
auvred marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| ], | ||
| invalid: [ | ||
| ...nullishTypeInvalidTest((nullish, type) => ({ | ||