DenoDDeno
Powered by
IAmKaleI
Denoβ€’17mo ago
IAmKale

Can I import/reference Deno's TypeScript when bundling types?

I have the following import in a script that uses
ts-morph
ts-morph
to pull some types from TypeScript (TypeScript is currently pulled in via package.json as an entry in
devDependencies
devDependencies
):

import { version } from 'typescript';
import { version } from 'typescript';


However when I try to run this script using
deno run
deno run
I get the following error:

error: Relative import path "typescript" not prefixed with / or ./ or ../ and not in import map from "file:///Users/me/blah/extract-types.ts"
error: Relative import path "typescript" not prefixed with / or ./ or ../ and not in import map from "file:///Users/me/blah/extract-types.ts"


Which is leading me to believe that TypeScript is not implicitly made global when Deno runs a script, and so I need to specify an entry for it in deno.jsonc's
"imports"
"imports"
property. Seems straightforward enough.

However, I'm hoping there's a way to do so that says, "use the TypeScript bundled with Deno" instead of having to make sure I keep the declared import in sync with whatever version of Deno I'm using with the project.

Is this possible?
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,934Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

`deno vendor` + `/// <reference types=...>` ?
Carlos ScheideggerCCarlos Scheidegger / help
2y ago
Compiled Deno project can't import typescript code
localhostLlocalhost / help
14mo ago
React types without @deno-types before every import?
Steve ASSteve A / help
14mo ago
Deno Types
mostprodevMmostprodev / help
3y ago