-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
allow PrivateIdentifier in QualifiedName #48640
Conversation
This PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise. |
This seems like an API change that has to happen thanks to the cast noted in: #47696 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We looked at this in the design meeting, and we think that it's the case that the right change is to instead make TypeQueryNode['exprName']
be PropertyAccessEntityNameExpression
instead of EntityName
.
@jakebailey As I understand your last comment, need to do the following list of items
TypeScript/src/compiler/types.ts Lines 2354 to 2358 in 45faac7
TypeScript/src/compiler/parser.ts Lines 8449 to 8457 in 45faac7
TypeScript/src/compiler/factory/nodeFactory.ts Lines 1885 to 1891 in 45faac7
Am I right? |
I think there may have been a miscommunication when I read the notes, because maybe it's |
@jakebailey I think we can try to change |
Maybe; I can see that coming up in #48763. |
I think we shouldn’t change the behavior of #19707 at this point post-beta. My suggestion would be (for now) to parse only a dotted name still, and pick whatever legal type for the API makes sense. (Note: changing |
I'm looking at this currently, and the trouble I'm seeing is that TypeQuery contains an export interface QualifiedName extends Node {
readonly kind: SyntaxKind.QualifiedName;
readonly left: EntityName;
readonly right: Identifier;
/*@internal*/ jsdocDotPos?: number;
}
export type EntityName = Identifier | QualifiedName; What was broken about #47696 was that there was a cast to So if we make I almost think we should revert #47696 (then approach #19707 in a later release), unless you're seeing a more reasonable parser change here than I am. It seems like the options are:
I do think making it |
To be clear, this is just my opinion; I wouldn't change anything just yet as we haven't actually re-met to discuss a way forward (I'm just writing my thoughts down so I don't lose them). If you want to do that, I would send a different PR so we can still see what's going on in this one. |
What? This doesn’t follow. Changing I actually think instead of
FWIW this interpretation of It does sound like we should probably discuss this again briefly next Wednesday before putting more work into it, as what we do with the API now depends on what we want to do with the API long-term, which I think depends at least on whether we actually want to address #19707. Sorry for the confusion @a-tarasyuk. |
Sorry, I was just trying to state that regardless of the decision to change |
The plan for what the tree actually looks like will follow directly from what we choose for the API type:
There’s not so much a problem with the shape of the tree as there is a disagreement between the type and reality. |
We decided to revert the original change; I'll be sending a PR shortly to do it. |
I think a better approach would have been to allow class C {
#x: Foo;
private _x: Foo;
method() {
const p1: this[#x] = this.#x;
const p2: this["_x"] = this._x;
const obj = this;
const p3: typeof obj[#x] = this.#x; // parsed as `(typeof obj)[#x]`
const p4: typeof obj["_x"] = this._x; // parsed as `(typeof obj)["_x"]`
}
} This would mean adding a If you need to access the type of a private named class member outside of the class, you would need to introduce a type alias or interface for it. If a class makes a private-named index access type public, our declaration emit would also need to synthesize a type for it outside of the class. This means that the type |
Fixes #47696 (comment)