Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dora1998 committed Apr 17, 2023
1 parent 64cb69e commit a1c766c
Showing 1 changed file with 21 additions and 0 deletions.
Expand Up @@ -285,6 +285,11 @@ function test(a: unknown) {
`
function test<T>(a: T) {
return a ?? 'default';
}
`,
`
function test<T extends string | null>(a: T) {
return a ?? 'default';
}
`,
// Indexing cases
Expand Down Expand Up @@ -832,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')],
Expand Down Expand Up @@ -863,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';
}
Expand Down

0 comments on commit a1c766c

Please sign in to comment.