Skip to content

Disallow 'declare' modifier on private named properties #36345

Closed
@ajafff

Description

@ajafff

TypeScript Version: 3.8.0-dev.20200119

Search Terms:

Code

class C {
    declare #foo: number;
    constructor() {
        this.#foo = 1;
    }
}

Expected behavior:

Error on declare modifier as it doesn't make sense for private named properties.

Actual behavior:

No compile error. Instead the emit is invalid. Depending on the target either the property declaration is missing (ESNext) or the whole downleveling is not done at all.

Playground Link: http://www.typescriptlang.org/play/?target=7&ts=3.8.0-dev.20200119#code/MYGwhgzhAEDC0G8BQ1XQCYFNRgE6egGIAzAe1IC5oA7AVwFsAjTXAbhTWFOogBddawXqVwAKAJSIOaNLwAWASwgA6EuWgBeaAEZ2MgL5J9QA

Related Issues:

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions