Description
π Search Terms
helper symbol tslib
π Version & Regression Information
- This changed between versions 5.1.6 and 5.2.2
Tested via playground and reading its debug output.
β― Playground Link
π» Code
function fooDecorator(originalMethod: any, context: any) {}
export class Symbol { constructor() { } }
@fooDecorator
export class myClass {
constructor() {
const _newSym = new Symbol();
}
}
π Actual behavior
The generated js code for myClass
contains
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
Which will access my local variable Symbol
instead of window.Symbol
/globalThis.Symbol
.
π Expected behavior
The generated code should access globalThis.Symbol
in any case or perhaps only if the file contains a local variable (from class
, const
or import
) with a colliding name.
Additional information about the issue
I found this with an import { Symbol } from "./service";
call (roughly modelled via this Bug Workbench) but this should not change the main problem.
We started to use the class name Symbol
in our code (and public API) since 2014.
Right now we circumvent this issue by using different names inside the local file via alias names in import
/export
But this is hard to understand and maintain.