Once in a while, VSCode just won't suggest imports from Payload (Webstorm does it). Example in the image
Has anyone else come across this?
(This also often happens with React imports, e.g. writing "useEffect" if I haven't imported anything from React before)
For comparison: Webstorm does this. Not perfect, as it imports from the dist folder, but better than nothing
I've been seeing this as well...are you developing straight in a project or in a module src which then gets imported?
Mh what exactly do you mean with > module src which then gets imported?
Ahh nvm, thought imports were only broken if your components were in a parent directory
but I just tested it now in a starter project and there's still no autocomplete, I do remember these working though 😬
my react autocompletes work though
even without importing React first
Hm weirdly it does work in one other project of mine. But not in this one:
https://github.com/AlessioGr/payload-plugin-ai/tree/master/demomaybe it has a problem if there's a sub-project (= demo folder) inside a project?
lemmmme test it again
yeah doesn't work
I feel like that project structure really fucks with VS Code
ive had to add
@types/react
in mine
for dev deps
missed that crucial step lol
but i saw ^ too
ahhhh yeah you're totally right, that fixes it for React
Sadly not for the payload imports 😦
yeah payload ones still dont work, its extra annoying for the mystery (undocumented) imports
maybe we should have aliases for payload?
import { useHook } from 'payload/@utilities'
import { Button } from 'payload/@components'
idk if that'd complicate things more or improve dx though
hm what exactly would that improve, though?
hmm without intellisense not much at all...ignore that
for some reason, useAuth works here. But useField is not suggested
Idk maybe your alias stuff would help. It seems vs code is just too braindead to find .ts files in subfolders for certain projects
do you think its a subfolder issue or a silent error in its indexer?
ive never looked in the internals of vscode but it could be something odd...i almost never see intellisense not working
No idea. It is working for me, but not always. It seems to work for some things, and for some things it doesn't
And weirdly, you can't find anything about it online
You know what, Imma open up an issue on vs code and see what happens
good call
@paulpopus could you test if you can reproduce it too before I submit it?:
https://github.com/AlessioGr/payload-plugin-lexical/blob/vscode-autosuggest-bug/src/index.tsxsure, gimme a sec
i cant get useField nor useAuth to autocomplete
But "payload" does autocomplete right?
yeah
okay perfect!!
(useAuth stopped working for me as well)
so weird
and i see correct types for useField once it is imported
(alias) const useField: <T extends unknown>(options: Options) => FieldType<T>
import useField
Get and set the value of a form field.
hopefully it gets sorted quickly, quite an annoying issue
Yeah definitely. With their 5k+ issues, my hopes are quite low, though
Do react with a thumbs up to the issue, though! Apparently they look at those
added a comment too, hopefully it gets looked at...its the weekend though
hm @paulpopus
not sure what I think about this
yeah i just saw that
not happy with that answer
why can you import something but doesnt get auto-imported ?
and isn't it part of the package.json?
hmm before going deeper, @jmikrut any ideas?
hmmmmm
no clue
this is super interesting though
i think some imports might work if you have already imported something from one of the files somewhere
like, i just got
useAllFormFields
to autocomplete, but i couldn't get
useAuth
to autocomplete in the public demo....
so i'm thinking that there's gotta be a way to manually define which files should be indexed by TS in a node module
worth looking into this further but i must go to bed
That might explain why it sometimes works and sometimes doesn't. Maybe it also has something to do with the subfolders? Never had these issues when importing from top-level folders
pft, 4am here and still going strong 😅 but good night!
possibly. I think this will kill me if we don't get to the bottom of it
@denolfe we should look into this tomorrow 😈
i envy that
Hmm, very interesting, I can look into this
it likely has something to do with the
typings
property in our package.json being incorrect
we are looking into this
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.