fix typeof import("path").Foo.#private#48763
fix typeof import("path").Foo.#private#48763magic-akari wants to merge 1 commit intomicrosoft:mainfrom
typeof import("path").Foo.#private#48763Conversation
| static #m = 1; | ||
| static #f(x: typeof import("./lib").Bar.#m) {} | ||
| ~~ | ||
| !!! error TS2694: Namespace '"tests/cases/conformance/classes/members/privateNames/lib".Bar' has no exported member '#m'. |
There was a problem hiding this comment.
This error seems to be wrong, since Bar is Foo and thus it has the #m static field.
There was a problem hiding this comment.
I can't tell if it's completely correct or not.
In this PR, I convert SyntaxError into TypeError.
Maybe it should be counted as "external" access.
According to the latest nightly for TS,
import(..).X.#privis technically syntactically valid, but it will never be semantically valid because it counts as "external" access to the private member, which is disallowed.
...
Originally posted by @bradzacher in babel/babel#14454 (comment)
There was a problem hiding this comment.
I will try to add more test cases to determine which case is more reasonable and self-consistent.
There was a problem hiding this comment.
I think a comparable way to test this would be to stick private onto the non-# one and see what happens.
There was a problem hiding this comment.
I think a comparable way to test this would be to stick
privateonto the non-#one and see what happens.
I didn't manage to do it.
At first I tried to alias type Bar = typeof import("./lib").Bar, then I found I cannot use Bar.#m.
typeof import("./lib").Bar.#m does not imply (typeof import("./lib").Bar).#m.
it means typeof (import("./lib").Bar.#m).
What do you think about it?
There was a problem hiding this comment.
For private, I just meant to write something like:
// @strict: true
// @target: esnext
// @filename: main.ts
export class Foo {
private static m = 1;
static #f(x: typeof import("./lib").Bar.m) {}
}
// @filename: lib.ts
export { Foo as Bar } from "./main";Where the static thing is "private" via TS, not via ECMAScript's private identifiers. I was replying on my phone so couldn't write it myself, sorry about that.
There was a problem hiding this comment.
The AST should be changed. This PR is blocked by #48640.
typeof import()#48690