Skip to content

chore(experimental-utils): remove useless union types ast-utils predicates #3289

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

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions packages/experimental-utils/src/ast-utils/predicates.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import { AST_NODE_TYPES, AST_TOKEN_TYPES, TSESTree } from '../ts-estree';

function isOptionalChainPunctuator(
token: TSESTree.Token | TSESTree.Comment,
token: TSESTree.Token,
): token is TSESTree.PunctuatorToken & { value: '?.' } {
return token.type === AST_TOKEN_TYPES.Punctuator && token.value === '?.';
}
function isNotOptionalChainPunctuator(
token: TSESTree.Token | TSESTree.Comment,
): boolean {
function isNotOptionalChainPunctuator(token: TSESTree.Token): boolean {
return !isOptionalChainPunctuator(token);
}

function isNonNullAssertionPunctuator(
token: TSESTree.Token | TSESTree.Comment,
token: TSESTree.Token,
): token is TSESTree.PunctuatorToken & { value: '!' } {
return token.type === AST_TOKEN_TYPES.Punctuator && token.value === '!';
}
function isNotNonNullAssertionPunctuator(
token: TSESTree.Token | TSESTree.Comment,
): boolean {
function isNotNonNullAssertionPunctuator(token: TSESTree.Token): boolean {
return !isNonNullAssertionPunctuator(token);
}

Expand Down Expand Up @@ -209,7 +205,7 @@ function isAwaitExpression(
* Checks if a possible token is the `await` keyword.
*/
function isAwaitKeyword(
node: TSESTree.Token | TSESTree.Comment | undefined | null,
node: TSESTree.Token | undefined | null,
): node is TSESTree.KeywordToken & { value: 'await' } {
return node?.type === AST_TOKEN_TYPES.Identifier && node.value === 'await';
}
Expand Down