deno
deno copied to clipboard
lsp: incorrectly supports type checking of named imports of JSON modules
Deno language server (as vscode intellisense) prints no error, but deno run reject the following.
Reproducible steps
> deno --version
deno 1.17.1 (release, x86_64-pc-windows-msvc)
v8 9.7.106.15
typescript 4.5.2
test.json
{ "a": 3 }
test.ts
import { a } from "./test.json" assert { type: "json" };
console.log(a);
deno run --unstable -A ./test.ts
What I expected
Print 3
What I got
error: Uncaught SyntaxError: The requested module './test.json' does not provide an export named 'a'
import { a } from "./test.json" assert { type: "json" };
^
Per spec this is not supported.
The json file that you are importing doesn't have to be an object.
4
"hello world"
[1, 2, 3]
All of the above examples are valid JSON and there's no way to make them work with destructuring syntax and thus it's not supported. (Also named imports are live bindings, whereas default import is not)
It is also a design limitation about it being "acceptable" in Deno Language Server, though we should try harder to fix it if we can.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.