htmltypescriptvisual-studio-codesveltesveltekit

How to undo a refactor that altered base types in frontend framework?


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 type HTMLProps<"div", HTMLAttributes<any>>.

How can I reset the base types back to what they should be? Here are some things I've already tried:


Solution

  • 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.