How did you serialize images? I have a type error, and I'm not sure if I'm supposed to write my own type for it. I feel like I'm not and I'm just being an idiot somewhere?
#Trouble Serializing Images - Type Error Issue
60 messages · Page 1 of 1 (latest)
Original message from @grim forge - Moved from #general message
Help is on the way! To mark it as solved, use the /solve command. In the meantime, here are some existing threads that may help you:
Documentation:
Community-Help:
What's the type before you declare one with as
SerializedLexicalNode
I feel like it should be SerializedUploadNode but that doesn't exist yet
whats the rest of the code look like
im looking at other exampels on github
GitHub
Deploys to Payload Cloud and Vercel. Contribute to mattddean/payloadcms-nextjs-pnpm-monorepo development by creating an account on GitHub.
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
where they do like
type SerializedLexicalNode =
| SerializedLexicalNodeText
| SerializedLexicalNodeLink
| SerializedLexicalNodeLinebreak
| SerializedLexicalNodeList
| SerializedLexicalNodeListitem
| SerializedLexicalNodeHeading
Hmm, good question
if i search img in the types file, it doesn't exist either. so maybe i should just manually write out the type.
it makes sense to serialise because then it's in the correct order and you can move the img's around
dunno, but the code works fine
it just has a type error
Hmm
so in that way i think i've done things right. i should just manually write the types, which is fine but i'm not used to doing that as a lot of payload types are prewritten
thank you!
I'm so close to leaving it as any, but I'm too much of a perfectionist lol
Lmao I feel that
We have like 2-3 anys in our work repo
and I'm convinced they are unsolveable so I have an ignore rule on them for lint specifically lol
Unsolveable as in, out of my control without more trickery
What you could do is
Make a new type that is like
yeah i get you. if i have to write 50 lines of code to solve this, i'm not sure if there's much point. unless it errors somehow, but it's a pretty simple thing
blah: SerializedNode & {otherProp: string}
so that you're not using any
but specifying an extended type
yeah i might do that. i tried but it said error converting type, so i went downstairs and bit into chocolate
ill try that again and see if it works
Valid result
lmao
Yeah lmk, most of the team is still waking up (im not on the team)
but maybe someone with more insight will pop in
thank you for the help! I'll see how it goes
interface MyNewType extends SerializedLexicalNode {
value: {
url: string;
};
}
that solves it
thank you! i am happy now
If you're going to be confused with types anywhere in the project
yeah i think it just wasn't in the code by default, so im happy
thank you so much! haha. that was easy with the extends feature
anytime