Open
Description
🔎 Search Terms
mixin symbol not imported function property
🕗 Version & Regression Information
- This changed between version 3.7.7 and 3.8.1, it went from working to being an error.
- This changed between version 4.2.4 and 4.3.2, it went from being an error to invalid.
⏯ Playground Link
💻 Code
import { mixin } from "./ref";
class Foo extends mixin(class {}) {
}
export { Foo }
// @filename: ref.ts
const sym = Symbol()
function mixin<T extends new (...args: any[]) => object>(base: T) {
abstract class M extends base {
[mixin.sym] = true
}
return M
}
mixin.sym = sym;
export { mixin }
🙁 Actual behavior
The symbol sym
is not referenced properly in the emitted .d.ts
it is an undefined name, nor is an error thrown:
import { mixin } from "./ref";
declare const Foo_base: (abstract new (...args: any[]) => {
[sym]: boolean;
}) & {
new (): {};
};
declare class Foo extends Foo_base {
}
export { Foo };
🙂 Expected behavior
The symbol sym
should be referenced as it's used mixin.sym
import { mixin } from "./ref";
declare const Foo_base: (abstract new (...args: any[]) => {
[mixin.sym]: boolean;
}) & {
new (): {};
};
declare class Foo extends Foo_base {
}
export { Foo };
or an error should be thrown.
Additional information about the issue
From v3.3.3 to v3.7.7 this technique worked as expected. From v3.8.1 to v4.2.4 this technique resulted in a compiler error. And from v4.3.2 onward this technique has emitted invalid code.
This bug surfaced trying to workaround the fact that const sym
is not exported and is a private name.