Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(experimental-utils): fix eslint-utils' negative predicates' return types #3462

Merged
merged 1 commit into from Jun 17, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/experimental-utils/src/ast-utils/predicates.ts
Expand Up @@ -5,7 +5,12 @@ function isOptionalChainPunctuator(
): token is TSESTree.PunctuatorToken & { value: '?.' } {
return token.type === AST_TOKEN_TYPES.Punctuator && token.value === '?.';
}
function isNotOptionalChainPunctuator(token: TSESTree.Token): boolean {
function isNotOptionalChainPunctuator(
token: TSESTree.Token,
): token is Exclude<
TSESTree.Token,
TSESTree.PunctuatorToken & { value: '?.' }
> {
return !isOptionalChainPunctuator(token);
}

Expand All @@ -14,7 +19,9 @@ function isNonNullAssertionPunctuator(
): token is TSESTree.PunctuatorToken & { value: '!' } {
return token.type === AST_TOKEN_TYPES.Punctuator && token.value === '!';
}
function isNotNonNullAssertionPunctuator(token: TSESTree.Token): boolean {
function isNotNonNullAssertionPunctuator(
token: TSESTree.Token,
): token is Exclude<TSESTree.Token, TSESTree.PunctuatorToken & { value: '!' }> {
return !isNonNullAssertionPunctuator(token);
}

Expand Down