Skip to content

Bug: ThrowStatement's argument should be Expression #9610

Closed
@ericmorand

Description

@ericmorand

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Relevant Package

ast-spec

Issue

According to the ECMAScript specification, ThrowStatement is required to have an expression as argument:

https://tc39.es/ecma262/#sec-throw-statement

But in ast-spec, the argument is exposed as a statement or null:

https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/ast-spec/src/statement/ThrowStatement/spec.ts

import type { AST_NODE_TYPES } from '../../ast-node-types';
import type { BaseNode } from '../../base/BaseNode';
import type { TSAsExpression } from '../../expression/TSAsExpression/spec';
import type { Statement } from '../../unions/Statement';

export interface ThrowStatement extends BaseNode {
  type: AST_NODE_TYPES.ThrowStatement;
  argument: Statement | TSAsExpression | null;
}

Versions

package version
@typescript-eslint/types 7.16.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    ASTPRs and Issues about the AST structureaccepting prsGo ahead, send a pull request that resolves this issuebugSomething isn't workinggood first issueGood for newcomerslocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions