DEV Community

Discussion on: Building Chrome extension with Vite ⚡️

Collapse
 
aderchox profile image
aderchox

You've tagged TypeScript but there's no explanation on how to add extension development types. Only a -ts Vite template will not do miracles to add the right types.

Collapse
 
rgolawski profile image
Rafał Goławski

You're right, good point. I forgot about it because I didn't need anything from Chrome API in this example. Try running npm i -D @types/chrome or yarn add --dev @types/chrome, it should do the job.

Collapse
 
aderchox profile image
aderchox

Thanks, but I've done this and it doesn't work. I'm using VSCode and the intellisense is completely unaware of any chrome types. Can you try this yourself too in a quick example project?

Thread Thread
 
jpwebdev1337 profile image
JP • Edited

Have you registered the types in your .tsconfig?

{
  // ...
  "compilerOptions": {
    // ...
    "types": ["chrome"],
  }
}
Enter fullscreen mode Exit fullscreen mode

Mentioned here as well.

Collapse
 
80avin profile image
Avinash Thakur • Edited

What about chrome-types, which is mentioned in official docs ? developer.chrome.com/docs/extensio...

I see for some reason, it doesn't have much downloads also.