Skip to content

Enhancement: throw an error for invalid TSParameterPropertys #11708

@bradzacher

Description

@bradzacher

Before You File a Proposal Please Confirm You Have Done The Following...

Relevant Package

ast-spec

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

class Test1 {
  constructor(
    private [foo] = [1],
    private { bar } = { bar: 1 },
    private ...baz
  ) { }
}

Currently these three parameter properties are semantic errors in TS and are similarly allowed by our parser.
However they are all non-sensical. The first two don't even transpile to generate a property!

We should make these hard errors to block the syntax so that we can refine our TSParameterProperty.parameter type to exclude the invalid states.

An additional case which is already a hard TS parser error that we should pre-narrow the types for -- the .left of an assignment parameter property must always be an Identifier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ASTPRs and Issues about the AST structureaccepting prsGo ahead, send a pull request that resolves this issueenhancementNew feature or requestpackage: ast-specIssues related to @typescript-eslint/ast-specpackage: 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