ChrisGo
ChrisGo•5mo ago

Import-IntelliSense with Fresh and VSCode doesn't work as expected

Hey. I'm fairly new to Deno and Fresh so I assume I'm simply missing something. I've created a Fresh project through the official guide, installed and enabled the Deno extension in VSCode. However when trying to use the Auto-Import feature with Intellisense it often doesn't pick up new files or creates non-optimal statements. - It doesn't pick up new files in non-standard folders. E. g. I've created a lib/ folder besides components/, islands/ and so on. Is this allowed? - Import suggestions for packages like std contain the explicit version and don't respect the import map from deno.json. So I'll get an import statement like import { basename } from "https://deno.land/std@0.211.0/path/basename.ts"; instead of import { basename } from "$std/path/basename.ts"; or import { basename } from "@std/path/basename";
3 Replies
Deno AI Helper
Deno AI Helper•5mo ago
Hello! It sounds like you're experiencing a couple of issues with IntelliSense and auto-imports in your Fresh project within VSCode. Let's address each of your concerns: 1. IntelliSense not picking up new files in non-standard folders: According to the documentation, when attempting to import a relative module specifier (one that starts with ./ or ../), import completions are provided for directories and files that Deno thinks it can run, which includes files ending with the extensions .ts, .js, .tsx, .jsx, or .mjs. If your new files in the lib/ folder have one of these extensions and are still not being picked up, you might want to ensure that the Deno extension is properly configured for your workspace and that the files are saved on disk. 2. Import suggestions containing explicit versions and not respecting the import map: The documentation mentions that the Deno language server supports completions for URLs and should provide module registry completions. However, it also notes that for the IntelliSense to respect import maps, you need to have the import map specified in your configuration. Make sure that the deno.json file is correctly set up with the import map and that the Deno extension is configured to use this file. If the path to the import map is relative, it should be resolved relative to the root of the workspace. If you're still getting explicit version numbers in your import statements, it could be due to the IntelliSense not correctly using the import map or a caching issue. You can try reloading the VSCode window or restarting the Deno language server to see if that resolves the issue. Remember that the Deno extension for VSCode should be enabled and properly configured for your workspace to get the most out of
Deno AI Helper
Deno AI Helper•5mo ago
its features. If you continue to experience issues, you might want to check the extension settings and ensure that the deno.enable setting is set to true for your workspace, and that the deno.importMap setting points to your deno.json file. If these suggestions don't resolve your issues, it could be helpful to look at the language server status or consult the Deno community for more specific guidance. 🦕
ChrisGo
ChrisGo•5mo ago
Unfortunately the AI response doesn't help me.