Microsoft/TypeScript
GitHub ã§èŠãJS output contains imports only used in types when `emitDecoratorMetadata: true`
Open
#42,301 opened on 2021幎1æ12æ¥
BugDomain: DecoratorsHelp Wanted
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
Bug Report
ð Search Terms
- emitDecoratorMetadata require
- emitDecoratorMetadata import
ð Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about 3.3.3, 4.1.3
⯠Playground Link
Playground link with relevant code
ð» Code
import * as vscode from 'vscode';
function LogMethod(
target: any,
propertyKey: string | symbol,
descriptor: PropertyDescriptor
) {
console.log(target);
console.log(propertyKey);
console.log(descriptor);
}
class Demo {
@LogMethod
public foo(bar: vscode.Memento) {
// do nothing
}
}
const demo = new Demo();
ð Actual behavior
The output contains const vscode = __importStar(require("vscode")); when emitDecoratorMetadata: true but not when emitDecoratorMetadata: false
ð Expected behavior
As the type of bar as nothing to do with the compiled JS, the import of vscode should not exist regardless of the value of emitDecoratorMetadata