I have a simple TypeScript tsconfig.json:
{
"compilerOptions": {
"target": "esnext",
"experimentalDecorators": true,
...
And a class that uses a decorator:
class MyClass {
@myDecorator()
myField: any;
}
The decorator causes myField to be emitted as a property that uses a __decorate function, the myDecorator function is passed to it.
After upgrading to the latest version (4.2.4) this stopped working in Visual Studio 2019, but it continues to work in VS Code (using 4.3.5) and continuous integration tools (in both 4.3.5 and older 3.* TypeScript releases).
After some investigation it appears that the emitted JavaScript has changed to include the fields explicitly, but only in the TypeScript 4.2.4 embedded in Visual Studio 2019. These explicit fields cause the __decorate to fail to create the new property with the same name.
Why has the emitted JS changed?
How do I fix it?
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment