Also, in recent versions of Deno (starting with 1.5), we have started to use a
Rust library to do transformations of TypeScript to JavaScript in certain
scenarios. Because of this, there are certain situations in TypeScript where
type information is required, and therefore those are not supported under Deno.
If you are using as stand-alone, the setting to use is "isolatedModules"
and setting it to true
to help ensure that your code can be properly handled
by Deno.
One of the ways to deal with the extension and the lack of magical resolution is to use which would allow you to specify “packages” of bare specifiers which then Deno could resolve and load.
Deno is built with a specific version of TypeScript. To find out what this is, type the following on the command line:
We do not consider changes in behavior or breaking changes in TypeScript
releases as breaking changes for Deno. TypeScript is a generally mature language
and breaking changes in TypeScript are almost always “good things” making code
more sound, and it is best that we all keep our code sound. If there is a
blocking change in the version of TypeScript and it isn’t suitable to use an
older release of Deno until the problem can be resolved, then you should be able
to use --no-check
to skip type checking all together.
In addition you can utilize @ts-ignore
to ignore a specific error in code
that you control. You can also replace whole dependencies, using
import maps, for situations where a
dependency of a dependency isn’t being maintained or has some sort of breaking
change you want to bypass while waiting for it to be updated.
As of Deno 1.5 we defaulted to isolatedModules to true
and in Deno 1.6 we
removed the options to set it back to false
via a configuration file. The
isolatedModules option forces the TypeScript compiler to check and emit
TypeScript as if each module would stand on its own. TypeScript has a few type
directed emits in the language at the moment. While not allowing type directed
emits into the language was a design goal for TypeScript, it has happened
anyways. This means that the TypeScript compiler needs to understand the
erasable types in the code to determine what to emit, which when you are trying
to make a fully erasable type system on top of JavaScript, that becomes a
problem.
So instead of trying to get every user to understand when and how we could
support the type directed emits, we made the decision to disable the use of them
by forcing the isolatedModules option to true
. This means that even when we
are using the TypeScript compiler to emit the code, it will follow the same
“rules” that the Rust based emitter follows.
This means that certain language features are not supportable. Those features are:
const enum
is not supported.const enum
s require type information to direct the emit, as s get written out as hard coded values. Especially whenconst enum
s get exported, they are a type system only construct.export =
andimport =
are legacy TypeScript syntax which we do not support.
While tsc
supports language service plugins, Deno does not. Deno does not
always use the built in TypeScript compiler to do what it does, and the
complexity of adding support for a language service plugin is not feasible.
TypeScript does not support emitter plugins, but there are a few community
projects which hack emitter plugins into TypeScript. First, we wouldn’t want
to support something that TypeScript doesn’t support, plus we do not always use
the TypeScript compiler for the emit, which would mean we would need to ensure
we supported it in all modes, and the other emitter is written in Rust, meaning
that any emitter plugin for TypeScript wouldn’t be available for the Rust
emitter.