microsoft / microsoft/TypeScript

'super.prop' in static method should be allowed to access static properties of base class

Open
#42,215 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: classes
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Bug Report

🔎 Search Terms

super property access static

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about "super"
⏯ Playground Link

Playground link with relevant code

💻 Code
// @target: ES5
class Base {
    static method() {}
    static prop = 1;
    static get accessor() { return 1 }
}

class Derived extends Base {
    static fn() {
        super.method; // allowed, as expected
        super.accessor; // not allowed, not expected
        super.prop; // not allowed, not expected
    }
}
🙁 Actual behavior

super.accessor and super.prop are marked as error. That makes sense in instance methods, but not in static methods, because static properties are not on the prototype.

Related: #42214

🙂 Expected behavior

No error.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked TypeScript Playground and reproduce the static class example using the ES5 target. Trace the checker entry point for super property access, then verify that super.prop and super.accessor in the static method produce no errors while the existing super.method case remains valid.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.