I'm using the vscode intelephense extension, and writing some JS logic using laravel livewire. My objective is to send an event at a specific time to refresh some data.
To achieve this, my logic is something like:
document.addEventListener('livewire:load', function () {
const refreshTime = @this.refreshTime;
setTimeout(() => {
Livewire.emit('refresh');
}, refreshTime);
});
Although this works, the Intelephense extension reports an error on @this.refreshTime
:
Decorators are not valid here.javascript
Expression expected.javascript
Is there any way to prevent or ignore this error? I'm thinking something like eslint-disable-next-line
, but for intelephense. Solutions that avoid using @this
, @js
, and other invalid JS syntax would also be acceptable!
My current solution for this is to populate the data in an element:
And retrieve the values using the element's dataset. In my case, the element will only appear once per page, so I don't need to worry about ID collisions.