Version
24.0.2
Platform
Darwin Mac.lan 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:32:50 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6041 arm64
Subsystem
No response
What steps will reproduce the bug?
Install a package as a dev dependency, and then do a type only import like below:
import { type FromSchema, type JSONSchema } from 'json-schema-to-ts'
How often does it reproduce? Is there a required condition?
100%
What is the expected behavior? Why is that the expected behavior?
If an import only includes TypeScript types—even if it doesn’t use the import type { ... } shorthand syntax, such as import { type FromSchema, type JSONSchema } from 'json-schema-to-ts' —the module should not be loaded at runtime, just as it wouldn’t be with the import type shorthand: import type { FromSchema, JSONSchema } from 'json-schema-to-ts'.
What do you see instead?
Despite only importing types, the module is still loaded at runtime, leading to an error like:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'json-schema-to-ts'
if the package is only installed as a dev dependency.
Of course a user can rely on using the shorthand notation for a type only import to avoid this issue, but this is a bit quirky and hard to enforce in a large code base without using a well setuped prettier/biome/etc.
On my hand I had this issue because I used a codemod to convert my codebase and automatically fix verbatimModuleSyntax issues.
Additional information
It would be great to fix this issue and avoid people occasionally scratching their head at this despite a work around being available.
Version
24.0.2
Platform
Subsystem
No response
What steps will reproduce the bug?
Install a package as a dev dependency, and then do a type only import like below:
import { type FromSchema, type JSONSchema } from 'json-schema-to-ts'How often does it reproduce? Is there a required condition?
100%
What is the expected behavior? Why is that the expected behavior?
If an import only includes TypeScript types—even if it doesn’t use the
import type { ... }shorthand syntax, such asimport { type FromSchema, type JSONSchema } from 'json-schema-to-ts'—the module should not be loaded at runtime, just as it wouldn’t be with the import type shorthand:import type { FromSchema, JSONSchema } from 'json-schema-to-ts'.What do you see instead?
Despite only importing types, the module is still loaded at runtime, leading to an error like:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'json-schema-to-ts'
if the package is only installed as a dev dependency.
Of course a user can rely on using the shorthand notation for a type only import to avoid this issue, but this is a bit quirky and hard to enforce in a large code base without using a well setuped prettier/biome/etc.
On my hand I had this issue because I used a codemod to convert my codebase and automatically fix verbatimModuleSyntax issues.
Additional information
It would be great to fix this issue and avoid people occasionally scratching their head at this despite a work around being available.