My name is Samuel Braun, I am 24 and from Germany. I absolutely love learning and sharing knowledge about web development, especially in the frontend field which is why I made this account ✋
Not sure exactly what you mean with parsing at runtime. JSDoc wasn't meant to be run in the browser. But if you want to validate types for exmaple of an API you could use something like Zod. With Zod you can also type your code using the same schema a JSDoc:
constmyUserSchema=z.object({user:z.string(),age:z.number(),});// @type {z.infer<typeof myUserSchema>}constuser=awaitfetch("user.json");// Validate if data is actually same type as defined in the schema// Throws an error if notmyUserSchema.parse(user);
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
wondering: does it help in "parsing" runtime, in a browser? What is the effect perfomance-wise?
Not sure exactly what you mean with parsing at runtime. JSDoc wasn't meant to be run in the browser. But if you want to validate types for exmaple of an API you could use something like Zod. With Zod you can also type your code using the same schema a JSDoc: