Is it possible to enforce the structure of the block route object (with TypeScript)? #2649
Unanswered
lamereactor
asked this question in
Help and Questions
Replies: 2 comments
-
|
It's probably possible but I don't know how, maybe with a json schema and a ts plugin. You could also do definePage({
// ...
} satisfies MyStrictType) |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Thank you for your reply, I’m going to explore these options. Could you also let me know whether it’s possible to use variables (or something similar) in route blocks? For example : |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Let's say I have this code :
I would like to get a build-time error if, for example:
nameis not defined or is not astringmeta.requiresAuthis not defined or is not abooleanmeta.permissionis not defined or is not one of the strings'admin','user', or'guest'Is it possible to throw a build-time error if the object’s structure doesn’t match a given TypeScript type or something like that?
@posva tagging you as this relates to the recent addition of unplugged-vue-router — would really appreciate your insight. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions