🔎 Search Terms
isolatedModules import alias
🕗 Version & Regression Information
- This is the behavior in every version I tried: v5.1.1, v5.2.2, v5.3.0-dev.20230830
⏯ Playground Link
https://www.typescriptlang.org/play?importHelpers=true&experimentalDecorators=true&emitDecoratorMetadata=true&isolatedModules=true&noResolve=true&ts=5.3.0-dev.20230830#code/JYWwDg9gTgLgBAbwJIDsYFMoDMCGBjdAXziyghDgHIA6AehgE8x0BnSgbgChPRJY4AcqwwATVBmz50cALxxxmXAWpCWohZIJdOI9HgA2OKNLwQUa+SjABXGAC44OFA23oAHn3gGcLFnABiEBCInHBhcAACqDbwYGRgAIQOqupoilJchEA
💻 Code
import{Interface}from'./types';importNestedInterface=Interface.NestedInterface;declareconstInput: any;exportclassFoo{
@Inputprop!: NestedInterface;}🙁 Actual behavior
var_a;import{__decorate,__metadata}from"tslib";import{Interface}from'./types';varNestedInterface=Interface.NestedInterface;// <-- this can throw at runtimeexportclassFoo{}__decorate([Input,__metadata("design:type",typeof(_a=typeofNestedInterface!=="undefined"&&NestedInterface)==="function" ? _a : Object)],Foo.prototype,"prop",void0);🙂 Expected behavior
Either of the following would work, I think:
- Make this pattern an error, possibly requiring sth like
import type NestedInterface = Interface.NestedInterface; - Elide import equals
- Emit
var NestedInterface = ... using a runtime check, similarly as in the decorator metadata code
Additional information about the issue
Very similar to #49450
🔎 Search Terms
isolatedModules import alias
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?importHelpers=true&experimentalDecorators=true&emitDecoratorMetadata=true&isolatedModules=true&noResolve=true&ts=5.3.0-dev.20230830#code/JYWwDg9gTgLgBAbwJIDsYFMoDMCGBjdAXziyghDgHIA6AehgE8x0BnSgbgChPRJY4AcqwwATVBmz50cALxxxmXAWpCWohZIJdOI9HgA2OKNLwQUa+SjABXGAC44OFA23oAHn3gGcLFnABiEBCInHBhcAACqDbwYGRgAIQOqupoilJchEA
💻 Code
🙁 Actual behavior
🙂 Expected behavior
Either of the following would work, I think:
import type NestedInterface = Interface.NestedInterface;var NestedInterface = ...using a runtime check, similarly as in the decorator metadata codeAdditional information about the issue
Very similar to #49450