Skip to content

AwaitExpression does not include ImportExpression as possible value of argument property #4877

@G-Rath

Description

@G-Rath
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgQQMoBUD6A5A8gEQFFN0BNABUNQBo51Ur0oBTZuAXzgDMoIQ4A5AAEYATzDMAzgGMowMDAC0UgDbAAdjAD0AVxjAVkgQG4AsACgL0iOsnwAJsxjMoIDcwCS4aDFQQdUNJsALxwABQWcHDqEI4AXHQMGCzMAHTIAO4AhsAwhAAeYCySksA21BYAlAl2cuoA5nAAPtE6KipwwQB8iJFwwFzhMY6pWVD1OiDMmqliEp3BoWhYeEQkFFSpXpCwBUVSpTaVveZRUVpafewWfSwwAeqt7Wbm7MZAA

import { AST_NODE_TYPES, TSESTree } from '@typescript-eslint/utils';

const determineImportSource = (
  node: TSESTree.AwaitExpression,
): string | null => {
  if (node.argument.type === AST_NODE_TYPES.ImportExpression) {
    //
  }

  return null;
};

Expected Result

No errors

Actual Result

An error from TypeScript:

This condition will always return 'false' since the types 'AST_NODE_TYPES.ArrayExpression | AST_NODE_TYPES.ArrayPattern | AST_NODE_TYPES.ArrowFunctionExpression | AST_NODE_TYPES.AwaitExpression | AST_NODE_TYPES.CallExpression | AST_NODE_TYPES.ClassExpression | ... 18 more ... | AST_NODE_TYPES.TSTypeAssertion' and 'AST_NODE_TYPES.ImportExpression' have no overlap

Additional Info

Here's an AST tree showing that it's possible to have an import expression as the argument of an await expression:

await import('@jest/globals');

image

https://astexplorer.net/#/gist/bd61e9f9222ff844ddbd1748895d8f8f/07c5c90e2933a965ef5329f4eb68588910343271

Versions

package version
@typescript-eslint/types 5.20.0
TypeScript 4.6.3
node v14.18.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerspackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy