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): [no-unnecessary-condition] allow nullish coalescing for naked type parameter#6910
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.
fix(eslint-plugin): [no-unnecessary-condition] allow nullish coalescing for naked type parameter#6910
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 |
---|---|---|
@@ -280,6 +280,16 @@ function test(a: string | null | undefined) { | ||
` | ||
function test(a: unknown) { | ||
return a ?? 'default'; | ||
} | ||
`, | ||
` | ||
function test<T>(a: T) { | ||
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. [Testing] The cases of 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. Oh sorry, I added them! | ||
return a ?? 'default'; | ||
} | ||
`, | ||
` | ||
function test<T extends string | null>(a: T) { | ||
return a ?? 'default'; | ||
} | ||
`, | ||
// Indexing cases | ||
@@ -827,6 +837,14 @@ function test(a: string) { | ||
code: ` | ||
function test(a: string | false) { | ||
return a ?? 'default'; | ||
} | ||
`, | ||
errors: [ruleError(3, 10, 'neverNullish')], | ||
}, | ||
{ | ||
code: ` | ||
function test<T extends string>(a: T) { | ||
return a ?? 'default'; | ||
} | ||
`, | ||
errors: [ruleError(3, 10, 'neverNullish')], | ||
@@ -858,6 +876,14 @@ function test(a: null[]) { | ||
}, | ||
{ | ||
code: ` | ||
function test<T extends null>(a: T) { | ||
return a ?? 'default'; | ||
} | ||
`, | ||
errors: [ruleError(3, 10, 'alwaysNullish')], | ||
}, | ||
{ | ||
code: ` | ||
function test(a: never) { | ||
return a ?? 'default'; | ||
} | ||