-
-
Notifications
You must be signed in to change notification settings - Fork 2.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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
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, | ||
isNullableType, | ||
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 (!isNullableType(type)) { | ||
if (!isTypeFlagSet(type, ts.TypeFlags.Null | ts.TypeFlags.Undefined)) { | ||
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 and maybe an opt-out for v7. |
||
return; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dacarley threading #8262 (comment):
https://deploy-preview-8262--typescript-eslint.netlify.app/play/#ts=5.3.3&fileType=.ts&code=FAEwpgxgNghgTmABBA9gOwM4BdEDcZQCuYAXIoWgNZooDuaA3MPkUgD5uIDeAvk0A&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Y6RAM0WlqYSNkAC1pkA9gEMkyMswDm6KL2jjokcGAC%2BILUA&tsconfig=&tokens=false