Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ts/analyzer): handle private field access in derived class #151

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

littledivy
Copy link
Contributor

Handle private name field access in derived class.

class Base {
    #prop: number = 123;
    static method(x: Derived) {
        x.#prop
    }
}

class Derived extends Base {
    static method(x: Derived) {
        x.#prop;
    }
}
error[TS18013]: DebugContext(
    context: tried to access property of an object to calculate type of a member expression
    context: tried to access property of an object (instanceof  Derived;, id_ctx = Var)
    Prop=Private(PrivateName { span: Span { lo: BytePos(168), hi: BytePos(173), ctxt: #0 }, id: prop#0 })
    context: tried to access property of an object (Derived;, id_ctx = Var)
    Prop=Private(PrivateName { span: Span { lo: BytePos(168), hi: BytePos(173), ctxt: #0 }, id: prop#0 })
    context: tried to access property of an object (this;, id_ctx = Var)
    Prop=Private(PrivateName { span: Span { lo: BytePos(168), hi: BytePos(173), ctxt: #0 }, id: prop#0 })
    CannotAccessPrivatePropertyFromOutside {
        span: Span {
            lo: BytePos(
                166,
            ),
            hi: BytePos(
                173,
            ),
            ctxt: #0,
        },
    },
)
  --> a.ts:10:9
   |
10 |         x.#prop;
   |         ^^^^^^^

Comment on lines +2 to +4
required_error: 4150,
matched_error: 5545,
extra_error: 1012,
Copy link
Contributor Author

@littledivy littledivy Oct 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kdy1 I'm not sure what required_error error mean relative to matched_error.

So far I've understood that (correct me if im wrong):

  • extra_errors are the ones that we should not be emiting but we do. This should go down.
  • matched_errors are the ones that matched expected errors. This still counts if there are extra_errors in a test case (?). This should go up.

matched_error - required_error = 5545 - 4150 = 1395 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

required_error means we have to emit those error for 100% parity with tsc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But well, I think we should document it somewhere, or change the name

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should rename it to missing_error

@kdy1 kdy1 self-assigned this Oct 31, 2022
@kdy1
Copy link
Member

kdy1 commented Oct 31, 2022

Oops I think we need a better way to track tsc stats.
It was fine for me because I was the only person working on stc, but it will make lots of rebasing necessary.
Any ideas?

@kdy1 kdy1 added this to the 4. 100% Parity milestone Oct 31, 2022
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm focusing on removing false-positive, so the increase of extra_error isn't acceptable

@kdy1 kdy1 removed their assignment Nov 13, 2022
@oadam
Copy link

oadam commented Jan 24, 2023

Oops I think we need a better way to track tsc stats. It was fine for me because I was the only person working on stc, but it will make lots of rebasing necessary. Any ideas?

This could be a plan :

  1. stop committing the error counts
  2. at the end of the github action build, publish the error counts as a github action artifact
  3. compare your stats to the stats contained in the artifacts of the last successful build of the main branch
  4. publish a comment on the PR comparing your stats to those of the main branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants