JC Brand on Nostr: Quite a while back, I read about how the #Svelte devs used JSDoc type hints together ...
Quite a while back, I read about how the #Svelte devs used JSDoc type hints together with the #TypeScript compiler to add types to Svelte while keeping the actual code #JavaScript.
I've decided to do the same with the #XMPP library Strophe.js
https://github.com/strophe/strophejsStrophe now contains type declaration files generated from the JSDoc type hints (not yet released).
My experience is a bit mixed.
Writing JSDoc types is more verbose and feels a bit more clunky than writing TypeScript.
But on the other hand, you avoid introducing a compilation step and the code itself doesn't have to change much.
For relatively small libraries like Strophe it's worth considering.
Published at
2023-07-27 07:49:25Event JSON
{
"id": "e1546bcf2cc7cd4c3663470719e18eb3f8a2fad2fb45639b27956bbd65b1512b",
"pubkey": "0f062633c211804dd8a0a441b933ecf8dd7255b02497ef4cd226cbbf7b3a5397",
"created_at": 1690444165,
"kind": 1,
"tags": [
[
"t",
"svelte"
],
[
"t",
"typescript"
],
[
"t",
"javascript"
],
[
"t",
"xmpp"
]
],
"content": "Quite a while back, I read about how the #Svelte devs used JSDoc type hints together with the #TypeScript compiler to add types to Svelte while keeping the actual code #JavaScript.\n\nI've decided to do the same with the #XMPP library Strophe.js\n\nhttps://github.com/strophe/strophejs\n\nStrophe now contains type declaration files generated from the JSDoc type hints (not yet released).\n\nMy experience is a bit mixed. \n\nWriting JSDoc types is more verbose and feels a bit more clunky than writing TypeScript.\n\nBut on the other hand, you avoid introducing a compilation step and the code itself doesn't have to change much.\n\nFor relatively small libraries like Strophe it's worth considering.\n\n",
"sig": "9e6ea8f26effb8fc133543576b8a0054c11f9bdaaf570ae814967b273b92789f72a83dc3251c529ef8210c0be0ed921d8d532598c7a6441a91df446311609888"
}