JacobZwangJ
Deno2y ago
5 replies
JacobZwang

How to import enums from npm:typescript package?

The following code crashes because the enum is undefined at runtime.
import * as ts from "npm:typescript";
console.log(ts.ScriptTarget.ESNext);

error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'ESNext')
  target: ts.ScriptTarget.ESNext,

I think this issue is related, but I can't figure out how to actually solve this. https://github.com/denoland/deno/issues/7605

I tried running it in Bun and it worked as expected and I can't find any compiler options in deno that seem related. How should I fix this?
GitHub
This error appears after I switched to Deno 1.4.1 and fixed all the import type errors. Skillz@Home Discordeno % deno run --allow-net --allow-read --unstable debug.ts error: Uncaught ReferenceError...
const enum error clarification · Issue #7605 · denoland/deno
Was this page helpful?