Ryan Bae
Ryan Bae

Reputation: 15

How do I get jsconfig.json working for a chrome extension on vscode?

I just created a jsconfig.json file with the line below at the root of my project:

{"typeAcquisition": {"include": ["chrome"]}}

My intellisense for chrome api still doesnt seem to work. Does anyone know what might be the problem? Do I need to add something else to my jsconfig for vscode to be able to read it?

Upvotes: 0

Views: 197

Answers (2)

rugk
rugk

Reputation: 5563

BTW for Firefox, you similarly install and use the @types/firefox-webext-browser in a very similar fashion:

npm i --save-dev @types/firefox-webext-browser

And then adjust your tsconfig.json or jsconfig.json:

{
  "compilerOptions": {
    "types": ["firefox-webext-browser"]
  },
}

Proof showing it works when typing browser.pr, it is showing privacy and other auto-completions

Upvotes: 0

typed-sigterm
typed-sigterm

Reputation: 1067

However, according to VS Code Docs, there isn't an option typeAcquisition in jsconfig.json. Only tsconfig.json supports that.


Although you are not using TypeScript, VS Code knows tsconfig.json. Use this:

{
  "compilerOptions": {
    "types": ["chrome"]
  }
}

Run:

pnpm add -D @types/chrome

it works

Upvotes: 0

Related Questions