You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This syntax could allow swc and other tools to drop the imports entirely without having to lookup whether or not they are erasable types or concrete values. This could mean many modules that just contain types never need to be fetched in the first place, it feels like it could have performance benefits when running a Deno app for the first time, although I've not confirmed this, and I've not found any attempts elsewhere to investigate it.
I don't know whether swc currently optimises using the type annotations (does it actually ignore import type modules entirely - i've tried looking in the codebase, but I'm unable to determine so, maybe some a bit more familiar with it could confirm), but I imagine it could, and other tools could potentially benefit from not having to follow these imports too.
At present, it's entirely up to the developer whether to mark imports with type in this way, and the type checking doesn't advise on this either, unless verbatimModuleSyntax is enabled.
It's currently possible to set this config in compilerOptions of deno.json, and it only affect your local code checks, (ie. it's not enforced on any remote lib you import), so I'm wondering, could there be an overall benefit across the ecosystem if explicit import type was encouraged and enforced by default in Deno 2.
For existing projects where this is not immediately desirable it could still be disabled by setting it to false in the deno.json config.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Introduced in TypeScript 5.0... https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/#verbatimmodulesyntax
The
verbatimModuleSyntax
option requires that type only imports are explicitly marked as such, for example:This syntax could allow swc and other tools to drop the imports entirely without having to lookup whether or not they are erasable types or concrete values. This could mean many modules that just contain types never need to be fetched in the first place, it feels like it could have performance benefits when running a Deno app for the first time, although I've not confirmed this, and I've not found any attempts elsewhere to investigate it.
I don't know whether swc currently optimises using the
type
annotations (does it actually ignoreimport type
modules entirely - i've tried looking in the codebase, but I'm unable to determine so, maybe some a bit more familiar with it could confirm), but I imagine it could, and other tools could potentially benefit from not having to follow these imports too.At present, it's entirely up to the developer whether to mark imports with
type
in this way, and the type checking doesn't advise on this either, unlessverbatimModuleSyntax
is enabled.It's currently possible to set this config in compilerOptions of deno.json, and it only affect your local code checks, (ie. it's not enforced on any remote lib you import), so I'm wondering, could there be an overall benefit across the ecosystem if explicit import
type
was encouraged and enforced by default in Deno 2.For existing projects where this is not immediately desirable it could still be disabled by setting it to
false
in the deno.json config.Beta Was this translation helpful? Give feedback.
All reactions