🔎 Search Terms
transpileModule, isolatedModules
🕗 Version & Regression Information
- This is the behavior in every version I tried: v5.2.2, v5.3.2, v5.4.0-dev.20231123
⏯ Playground Link
Bug Workbench
💻 Code
// @isolatedModulesimport{Date}from"./types";functionfoo(a: Date){constb=newDate(a.year,a.month,a.day);returnb.getTime();}// @filename: types.d.tsexportinterfaceDate{day: number;month: number;year: number;}🙁 Actual behavior
Regular emit:
functionfoo(a){constb=newDate(a.year,a.month,a.day);returnb.getTime();}ts.transpileModule() emit:
import{Date}from"./types";functionfoo(a){constb=newDate(a.year,a.month,a.day);returnb.getTime();}The ts.transpileModule() emit has a runtime error because the imported Date either doesn't exist or doesn't have a constructor.
🙂 Expected behavior
Same (or at least runtime equivalent) emit of transpileModule.
Additional information about the issue
I realize this code is probably not ideal. I was honestly surprised that this type-checks. I'm happy with any solution here:
- Make this code an error in all configurations.
- Make
isolatedModules require import type. - ...
🔎 Search Terms
transpileModule, isolatedModules
🕗 Version & Regression Information
⏯ Playground Link
Bug Workbench
💻 Code
🙁 Actual behavior
Regular emit:
ts.transpileModule()emit:The
ts.transpileModule()emit has a runtime error because the importedDateeither doesn't exist or doesn't have a constructor.🙂 Expected behavior
Same (or at least runtime equivalent) emit of transpileModule.
Additional information about the issue
I realize this code is probably not ideal. I was honestly surprised that this type-checks. I'm happy with any solution here:
isolatedModulesrequireimport type.