Skip to content

Commit

Permalink
chore: more test coverage; I'd missed a couple of keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Feb 2, 2022
1 parent 9742e45 commit 3c1c524
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Expand Up @@ -44,6 +44,8 @@ const keywordNodeTypesToTsTypes = new Map([
[TSESTree.AST_NODE_TYPES.TSAnyKeyword, ts.TypeFlags.Any],
[TSESTree.AST_NODE_TYPES.TSBigIntKeyword, ts.TypeFlags.BigInt],
[TSESTree.AST_NODE_TYPES.TSBooleanKeyword, ts.TypeFlags.Boolean],
[TSESTree.AST_NODE_TYPES.TSNeverKeyword, ts.TypeFlags.Never],
[TSESTree.AST_NODE_TYPES.TSUnknownKeyword, ts.TypeFlags.Unknown],
[TSESTree.AST_NODE_TYPES.TSNumberKeyword, ts.TypeFlags.Number],
[TSESTree.AST_NODE_TYPES.TSStringKeyword, ts.TypeFlags.String],
]);
Expand Down
Expand Up @@ -13,8 +13,19 @@ const ruleTester = new RuleTester({

ruleTester.run('no-redundant-type-constituents', rule, {
valid: [
'type T = any;',
'type T = never;',
`
type T = any;
type U = T;
`,
`
type T = never;
type U = T;
`,
`
type T = 1 | 2;
type U = T | 3;
type V = U;
`,
'type T = () => never;',
'type T = () => never | string;',
`
Expand All @@ -36,7 +47,6 @@ ruleTester.run('no-redundant-type-constituents', rule, {
type B = never;
type T = { new (): string | B };
`,
'type T = unknown;',
`
type B = unknown;
type T = B;
Expand Down Expand Up @@ -134,6 +144,11 @@ ruleTester.run('no-redundant-type-constituents', rule, {
type B = string;
type T = B & null;
`,
'type T = `${string}` & null;',
`
type B = \`\${string}\`;
type T = B & null;
`,
],

invalid: [
Expand Down Expand Up @@ -224,6 +239,22 @@ ruleTester.run('no-redundant-type-constituents', rule, {
},
],
},
{
code: `
type B = never;
type T = B | number;
`,
errors: [
{
column: 18,
data: {
container: 'union',
typeName: 'never',
},
messageId: 'overridden',
},
],
},
{
code: 'type T = never | number;',
errors: [
Expand Down

0 comments on commit 3c1c524

Please sign in to comment.