Hi. I want to use alpine.js inside of a <script> in an .astro component. I have added alpine via the pnpm astro add alpinejs command to my project.
My Astro component has a <script> at the bottom like this:
<script>
console.log(Alpine);
</script>
This works as expected (I believe) in runtime because the Alpine instance gets logged in the browser console, but I am getting type errors:
Cannot find name 'Alpine'.ts(2304)
Additionally, because I have auto-imports in VSCode, the editor tries to import the alpine library like this:
<script>
import Alpine from 'alpinejs';
console.log(Alpine);
</script>
But that's obviously not what we want.
How do I fix these type errors?