jamesbirtles / svelte-vscode

Svelte language support for VS Code
https://marketplace.visualstudio.com/items?itemName=JamesBirtles.svelte-vscode
MIT License
207 stars 22 forks source link

URL constructor available in <script>, but not {sveltecodehere} #95

Closed dragonwocky closed 4 years ago

dragonwocky commented 4 years ago

I know for a fact that using the constructor URL should be completely valid here. It runs without issue, and all the documentation/etc. I've read leads to me believe this should work. However, Svelte disagrees (image below shows svelte(missing-declaration) when constructor is used between {} within an attribute):

image

However, if I define it within the <script> tags up at the top (as below), and reference it via {animationspeed}, there are no lint errors.

const animationspeed = document.referrer
    ? new URL(document.referrer).host !== document.location.host
      ? "0.3s"
      : "0s"
    : "";