I'm using Svelte 5 and TypeScript in VS Code.
I'm running into an issue where the TS language server thinks that the style
attribute is not valid for a <div>
, which is obviously incorrect. I'm fairly certain I know what caused this: I have a component whose Props
interface extends HTMLAttributes<HTMLDivElement>
and includes a style
prop. I refactored (via F2) that prop to a different name at one point, and VS Code took a very long time to perform it, overriding the style
attribute in a ton of different files unrelated to that component.
I fixed the issues with my files, but I did not do so with an undo, since at the time I hadn't realized the gravity of the situation. The refactor must have altered some base type that the TS or Svelte language servers use for HTML elements, because now something like:
<div style="left: 40px;">Div</div>
throws an error:
Object literal may only specify known properties, and
"style"
does not exist in typeHTMLProps<"div", HTMLAttributes<any>>
.
How can I reset the base types back to what they should be? Here are some things I've already tried:
Users/.vscode/extensions
folder, then reinstalling..svelte-kit
and node_modules
folders and re-running the corresponding install and build steps.Most package managers have a cache for the packages somewhere and when that is somehow corrupted, a regular reinstall will not help. As noted in the comments, in this case PNPM's store cache needed to be nuked to fix the issue.