Skip to content

Error on static class members named 'constructor' should be consistent #33198

Open
@ark120202

Description

@ark120202

TypeScript Version: 3.7.0-dev.20190831

Search Terms: class, constructor, static, computed, quoted

Code

class A { static constructor() {} }
class B { static "constructor"() {} }
class C { static ["constructor"]() {} }

Expected behavior:

Even though it may be confused with non-standard extensions like #265, I think treating all cases equally would be less confusing, because unlike non-static ["constructor"] there is no difference at runtime.

Actual behavior:

A and B (with #31949) get a 'static' modifier cannot appear on a constructor declaration. diagnostic.

Playground Link:
http://www.typescriptlang.org/play/#code/MYGwhgzhAECC0G9oQC5hQS2NYB7AdqgE4CuwKuRAFAJSIC+09AUKJDAEKLJqbYBEeQilLlK-WgyatwUaAGFuqdFmgBtQQWJkKRfgF1JCRiyA

Related Issues: #31020, eslint/eslint#12110

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions