mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
9fa551a6ce
Fixes #13284. Fix semantic's checking of `super()` and `super.prop`. This fixes various TS test cases, notably correctly identifying that these are all illegal: ```js class C { prop = function() { super.foo }; [super.foo]() {} @super.foo method() {} }; ``` It also fixes various edge cases related to classes nested within other classes that aren't covered by existing conformance tests. It's pretty much a complete re-write. I've combined the 2 paths for in a class and not in a class into one, to avoid repeated code. This PR includes pass + fail test fixtures which include `super` in every conceivable position I could think of. There are so many errors in the fail test fixtures, that I had to write a script to check the snapshot includes them all! Hopefully this solves this issue for once and for all! Note: The large pass fixture seems to be revealing bugs somewhere in transformer - there's a mismatch, as well as lots of wrong scopes. But that's incidental to this PR, and can be addressed separately.
37 lines
745 B
TypeScript
37 lines
745 B
TypeScript
// Not sure this is correct, but adding this test to make sure it doesn't panic at least.
|
|
// See comment in `check_super` in `oxc_semantic`.
|
|
|
|
// `super()`
|
|
class C extends Super {
|
|
[keys: string]: typeof import('x', { with: super() }).y;
|
|
}
|
|
|
|
class D extends Super {
|
|
[keys: typeof import('x', { with: super() }).y]: string;
|
|
}
|
|
|
|
class Outer extends Super {
|
|
constructor() {
|
|
class Inner {
|
|
[keys: string]: typeof import('x', { with: super() }).y;
|
|
}
|
|
}
|
|
}
|
|
|
|
class Outer2 {
|
|
constructor() {
|
|
class Inner extends Super {
|
|
[keys: typeof import('x', { with: super() }).y]: string;
|
|
}
|
|
}
|
|
}
|
|
|
|
// `super.foo`
|
|
class E {
|
|
[keys: typeof super.foo]: string;
|
|
}
|
|
|
|
class F {
|
|
[keys: typeof import('x', { with: super.foo }).y]: string;
|
|
}
|