Replies: 2 comments
-
Hi @tordans Here are a few suggestions: 1. Triple-Slash Directives:In your TypeScript file where you're using Deno, try adding a triple-slash directive at the top:
Ensure that this line is at the top of your script file. This should make TypeScript aware of Deno types. 2. TypeScript Configuration (
|
Beta Was this translation helpful? Give feedback.
-
In addition to @kazunetakeda25's excellent answer, if you are using the Deno VS Code plugin, you can use // .vscode/settings.json
{
"deno.enablePaths": [
"scripts"
]
} |
Beta Was this translation helpful? Give feedback.
-
Kontext: I have a NextJS Project with a
scripts
folder. I want to use Deno to run the scripts in this folder and use things likeDeno.writeTextFile
.Issue: Right now,
Deno
is unkown ("Cannot find name 'Deno'. — ts(2304)").What I tried: I tried adding
/// <reference lib="deno.ns" />
to the script file or atypes.d.ts
in that folder or to import this types file in my script file … all don't solve the VS Code TS error.What I am looking for: Right now, I have Bun configured in the same way (NextJS with scripts folder which uses Bun). The types are working with
"compilerOptions": { "types": ["bun-types", "web"] }
in my projecttsconfig.json
.How do I solve this in Deno land?
Right now, it looks like that multi-root workspace as described by this FAQ https://docs.deno.com/runtime/manual/advanced/typescript/faqs#how-do-i-combine-deno-code-with-non-deno-code-in-my-ide are the only way to solve this in Deno land. However, that is very VS Code specific and also seems like a complex config since my script folder is part of the main project (so I would need to include/exclude this folder for the two workspaces?)… — So, is there a different way?
Beta Was this translation helpful? Give feedback.
All reactions