diff --git a/src/rules/tsUtils.ts b/src/rules/tsUtils.ts index 24ea20877..68c6b3546 100644 --- a/src/rules/tsUtils.ts +++ b/src/rules/tsUtils.ts @@ -72,7 +72,7 @@ export const isTemplateLiteral = ( (node.quasis.length === 1 && // bail out if not simple node.quasis[0].value.raw === value)); -export type StringNode = +type StringNode = | StringLiteral | TemplateLiteral; @@ -110,7 +110,7 @@ export const getStringValue = (node: StringNode): S => /** * Represents a `MemberExpression` with a "known" `property`. */ -export interface KnownMemberExpression +interface KnownMemberExpression extends TSESTree.MemberExpression { property: AccessorNode; } @@ -232,7 +232,7 @@ type AccessorNode = | StringNode | KnownIdentifier; -export interface ExpectCall extends TSESTree.CallExpression { +interface ExpectCall extends TSESTree.CallExpression { callee: AccessorNode<'expect'>; parent: TSESTree.Node; } @@ -257,7 +257,7 @@ export const isExpectCall = (node: TSESTree.Node): node is ExpectCall => /** * Represents a `MemberExpression` that comes after an `ExpectCall`. */ -export interface ExpectMember< +interface ExpectMember< PropertyName extends ExpectPropertyName = ExpectPropertyName, Parent extends TSESTree.Node | undefined = TSESTree.Node | undefined > extends KnownMemberExpression { @@ -278,8 +278,8 @@ export const isExpectMember = < /** * Represents all the jest matchers. */ -export type MatcherName = string /* & not ModifierName */; -export type ExpectPropertyName = ModifierName | MatcherName; +type MatcherName = string /* & not ModifierName */; +type ExpectPropertyName = ModifierName | MatcherName; export type ParsedEqualityMatcherCall< Argument extends TSESTree.Expression = TSESTree.Expression @@ -288,6 +288,11 @@ export type ParsedEqualityMatcherCall< arguments: [Argument]; }; +enum EqualityMatcher { + toBe = 'toBe', + toEqual = 'toEqual', +} + export const isParsedEqualityMatcherCall = ( matcher: ParsedExpectMatcher, ): matcher is ParsedEqualityMatcherCall => @@ -295,11 +300,6 @@ export const isParsedEqualityMatcherCall = ( matcher.arguments !== null && matcher.arguments.length === 1; -export enum EqualityMatcher { - toBe = 'toBe', - toEqual = 'toEqual', -} - export enum ModifierName { not = 'not', rejects = 'rejects',