top of page

Forum Posts

Jacob Kimchi
Velo Team
Velo Team
Jan 18, 2022
In Tips, Tutorials, Examples
Have you ever encountered the following validation error while coding in Velo? Cannot redeclare block-scoped variable x. Take a look at the below video which shows it in a more visualized way (for a const named 'schema'): Why does this happen? Velo currently uses a TypeScript compiler for autocomplete and code validations. Yes, Velo users TypeScript typing system to validate your Velo JS code :-) Read the explanation in this post, it will clarify things. If typescript recognizes a code file as a script (code that doesn’t include import or export statements) it shares global scope with all other script files. In Velo, there’s currently one global scope for everything (including frontend and backend - same scope). So Basically this could happen in two scenarios. One is that you are trying to declare a variable which you declared already in another “script" file Another scenario is that you declare a variable that collides with one of the properties of the global scope object. “name” is such an example when writing frontend code in Velo because it’s already been declared by the WebWorker (our frontend runtime environment) What can you do about it? Change your variable name (clever, hu?) Export or import something in one of the files in which you declare the variable, as it would make that file a module which has its own scope. Another option is to move that variable declaration to a function or the onReady event handler if that fits your need. Hope you’d find this helpful in case you’ve encountered this validation error. Got something to add? Please share it with us in the comments section below.
"Cannot redeclare block-scoped variable" validation error content media
4
0
947
Jacob Kimchi
Velo Team
Velo Team
Jan 17, 2022
In Coding with Velo
Hi everyone, We are collecting votes and use cases for this feature request: Dashboard Pages - Roles & Permissions If you’ve ever had the need in creating a dashboard page and you also wanted to restrict access in some specific way to some specific roles, we’d love to hear about it. Please do share your use case with us in the comments section below. You can also vote for it in the Wishlist (linked above). Thanks!
2
0
40
Jacob Kimchi
Velo Team
Velo Team
Jan 17, 2022
In Tips, Tutorials, Examples
Caching helps to significantly speed up a page’s loading time. Most pages on Wix Sites are cached automatically. However, pages with Velo code or dynamic content may be excluded from automatic caching. In these cases, you can enable caching manually to get the benefits of faster loading times. We’ve recently published an article which explains in detail about caching in Velo. We highly recommend reading it in case you have Velo code in your Wix website as this is something you should be aware of. And please share with us any inputs you might have about this topic or about the article specifically in the comments section below. Thanks!
7
1
353

Jacob Kimchi

Forum Moderator
Admin
Velo Team
+4
More actions
bottom of page