Skip to content

Conversation

@G-Rath
Copy link
Collaborator

@G-Rath G-Rath commented Jul 20, 2019

No description provided.

'test.skip',
]);

const isTestArrowFunction = (node: TSESTree.Node) =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is only used by ArrowFunctionExpression, so you can do node: TSESTree.ArrowFunctionExpression and ditch the undefined and node.type checks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually apparently I can leave it as TSESTree.Node, but yeah much better!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to widen the type when we don't need it 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the functions name (isTestArrowFunction), I think it should: either it should test that the type is ArrowFunctionExpression, or it should test if a given ArrowFunctionExpression is a "test" arrow function.

} from '@typescript-eslint/experimental-utils';

const isTestArrowFunction = node =>
const testCaseNames = new Set<string | null>([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null? seems wrong

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's just b/c of how the typings work in relation to #has.

Basically, it's defined like this:

interface Set<T> {
  has(item: T): boolean;
}

That means if T is just string, you can't do has checks against things like null, which is a possible return of getNodeName :)

Originally I had getNodeName(/* ... */) || '', but since that's a runtime solution, it's expected to be tested for by branch coverage 😂

const stack: Array<boolean> = [];

function validate(node) {
function validate(node: TSESTree.Node) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function validate(node: TSESTree.Node) {
function validate(node: TSESTree.ConditionalExpression | TSESTree.IfStatement) {

@SimenB SimenB merged commit b1f680e into jest-community:reapply-ts Jul 20, 2019
@G-Rath G-Rath deleted the ts-migration/no-if branch July 20, 2019 11:32
SimenB pushed a commit that referenced this pull request Jul 21, 2019
SimenB pushed a commit that referenced this pull request Jul 21, 2019
SimenB pushed a commit that referenced this pull request Jul 22, 2019
SimenB pushed a commit that referenced this pull request Jul 22, 2019
@SimenB SimenB mentioned this pull request Jul 22, 2019
35 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants