vscode_deno
vscode_deno copied to clipboard
deno.json not recognized if not at root of workspace
Describe the bug
If I define my deno.json
file at the root my workspace then I get proper Deno language support but if I put it in a folder then I do not.
To Reproduce
- Run "Deno: Initialize Workspace Configuration"
- Create a folder named "foo"
- Create a
deno.json
file in "foo" with some"imports"
defined (e.g. for std lib) - Create a
main.ts
file in "foo" and import something leveraging the "imports" defined in thedeno.json
file
Note how you'll get an error message from VSCode:
Relative import path "$std/flags/mod.ts" not prefixed with / or ./ or ../deno(import-prefix-missing)
However running deno run foo/main.ts
works fine (and creates a deno.lock
file too)
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..01cede9
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,5 @@
+{
+ "deno.enable": true,
+ "deno.lint": true,
+ "deno.unstable": false
+}
\ No newline at end of file
diff --git a/foo/deno.json b/foo/deno.json
new file mode 100644
index 0000000..55ca111
--- /dev/null
+++ b/foo/deno.json
@@ -0,0 +1,5 @@
+{
+ "imports": {
+ "$std/": "https://deno.land/[email protected]/"
+ }
+}
diff --git a/foo/main.ts b/foo/main.ts
new file mode 100644
index 0000000..57ebaf7
--- /dev/null
+++ b/foo/main.ts
@@ -0,0 +1,3 @@
+import { parse } from "$std/flags/mod.ts";
+
+console.log(parse(Deno.args));
Expected behavior
The VSCode Deno extension should provide code completion inside the subfolder just as it would if deno.json
were at the root of the workspace instead.
Screenshots
Versions
vscode: 1.82.2 deno: 1.37.0 extension: 3.23.1
This will be coupled with #787. If you have only one subdirectory with a deno.json
, you can work around this in the meantime by specifying "deno.config": "foo/deno.json"
in your workspace settings.