avatar
{🧪} +paoloricciuti.svelte @paolo.ricciuti.me

Wouldn't this be better? You have information about the node already so you don't need a type argument no? tsplay.dev/W4YyOw

aug 13, 2025, 4:27 pm • 0 0

Replies

avatar
Michael Aufreiter @michaelaufreiter.com

Amazing! So what you do here is use the actual node object, and deriving the type from its shape, not the schema information? Limitation would be that you can't go beyond native types. In Svedit I have property 'node' and 'string'. both hold a string value, but the former is a node reference (id).

aug 13, 2025, 6:00 pm • 0 0 • view
avatar
Michael Aufreiter @michaelaufreiter.com

But the ultimate question is: Can this or the previous version work when turned into a d.ts file and a .js file with JSDoc? Couldn't do this fella here: It compiled but I ended up with `any` as the resulting type. bsky.app/profile/did:...

aug 13, 2025, 6:04 pm • 0 0 • view
avatar
{🧪} +paoloricciuti.svelte @paolo.ricciuti.me

Oh for sure, will also do that just wanted to know how you wanted it to work

aug 13, 2025, 6:10 pm • 1 0 • view
avatar
Michael Aufreiter @michaelaufreiter.com

Actually hard to say, your approach is a great improvement for DX already and no weird extra param needed. Though get(id, type) might be more "correct". I have a bunch of code that uses runtime inspection, so there it's fine to get `any` I think. Like this one here: github.com/michael/sved...

aug 13, 2025, 6:23 pm • 0 0 • view
avatar
Michael Aufreiter @michaelaufreiter.com

Nevermind, if I have a starting point with JSDoc I think I'll figure out the rest (sooner or later) :D

aug 13, 2025, 6:24 pm • 0 0 • view