Next.js Discord

Discord Forum

vscode type assist on imports

Unanswered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
What I want: import DashboardSkeleton from "@/app/ui/skeletons";
What I get: import DashboardSkeleton from "../ui/skeletons";

Working on the tutorial. I'd imagine it doesn't "really" matter, but it is annoying lol

Version: 1.90.0
Commit: 89de5a8d4d6205e5b11647eb6a74844ca23d2573
Date: 2024-06-04T19:43:07.605Z
Electron: 29.4.0
ElectronBuildId: 9593362
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Linux x64 6.8.0-35-generic snap

22 Replies

what does your jsconfig.json file look like?
Cape lionOP
fresh rig, so probably nothing, lemme dig
there should be a
 "compilerOptions": {
    "paths": {
      "@/*": ["./*"]
    }
  } 

inside of it
Cape lionOP
Yep, nothing, I do backend 99.9% of the time if you can't tell
and mostly in python or legacy nodejs without typescript
hrm, didn't work, but I wasn't able to enable the nextjs extension either
compiler options should be inside {} if you didnt put it
Cape lionOP
oh, maybe in the tsconfig.json file instead?
wdym about nextjs extension?
if you have a tsconfig file put it there ye
Cape lionOP
There was something in the installation on this tut about one

https://nextjs.org/learn/dashboard-app/streaming
that was already in the tsconfig file
if you change it on the import does it work?
with the @/ I mean
also, restart dev server just to be sure
Cape lionOP
It wasn't up, had just cold booted my rig
Ok, I can't find where I thought I saw something about an extension, but I swear it was somewhere in the Next docs.
so the problem lies on the automatical write of the line or that it doesnt work if you write @/?
Cape lionOP
It's the automatic write, largely seems to be working now, but I'd type

import Dash then arrow down to DashboardSkeleton and hit enter, and I'd get the un-expected output
I guess I should note, it's working on pages that already have @ style imports, I mostly notice it on new files
have you tried restarting vs code
Cape lionOP
yeah, it's working now on new files, no idea why it wasn't early now though, but I got bigger fish to fry, thanks for the help