Closed
Description
TypeScript Version: 3.9.0-dev.20200329
Search Terms: emitDecoratorMetadata type import
When combining emitDecoratorMetadata
with type-only imports, the generated code crashes at runtime. I've been unable to produce a repro on the playground, since it somehow adds another undefined check, so I'll show you real-world code where this happens:
- clone
https://github.com/AlCalzone/node-zwave-js/tree/41da020d7515826e3e8fc2e0c3fc24a0d3c19355
npm i
npm i -D [email protected]
npm run build
- look at the output file
build/lib/commandclass/MultiChannelCC.js
Code
This is the core of the problem
import type { Driver } from "../driver/Driver";
// ...
export class MultiChannelCC extends CommandClass {
// ...
public constructor(driver: Driver, options: CommandClassOptions) {
// ...
}
}
Expected behavior:
like on the playground link above
Actual behavior:
MultiChannelCC = __decorate([
CommandClass_1.commandClass(CommandClasses_1.CommandClasses["Multi Channel"]),
CommandClass_1.implementedVersion(4),
__metadata("design:paramtypes", [Driver, Object])
], MultiChannelCC);
Notice how the value side of Driver
is referenced at runtime, although the import is type-only.
Playground Link: Playground does not allow relative imports
Related Issues: #27519