Skip to content

Remove properties that are used by invalid code #4759

Closed
@bradzacher

Description

@bradzacher

Currently we have the following AST properties declared:

These all represent bad code that would cause errors if one attempted to build in TS:

public enum Foo {}
// 'public' modifier cannot appear on a module or namespace element.(1044)

abstract namespace Bar {}
// 'abstract' modifier can only appear on a class, method, or property declaration.(1242)

interface Baz implements Bam {}
// Interface declaration cannot have 'implements' clause.(1176)

abstract interface Bam {}
// 'abstract' modifier can only appear on a class, method, or property declaration.

TS parses these fine and emits a semantic error, not a syntactic error.
Our parser currently does not error on syntactically bad code, thus we also don't error on it (#1852).

We should remove these properties from the AST as it is non-sensical to include them - nobody should ever be inspecting the code that is produced on them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ASTPRs and Issues about the AST structureaccepting prsGo ahead, send a pull request that resolves this issuebreaking changeThis change will require a new major version to be releasedpackage: typescript-estreeIssues related to @typescript-eslint/typescript-estree

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions