To ensure your IDE provides correct TypeScript support for a Flarum extension, you must install flarum-tsconfig as a development dependency and create a tsconfig.json file in your extension's js folder. This configuration extends Flarum's standard settings and includes core typings for global namespaces like dayjs and $.
Prerequisites:
- Install the package via npm or yarn.
- Run
composer update in your extension's root directory to ensure Flarum core typings are available in the vendor directory.
Note: The vendor directory should not be committed to Git.
# Install the dependency
npm install --save-dev flarum-tsconfig
# or
yarn add --dev flarum-tsconfig
# Create a tsconfig.json in your js folder
```jsonc
{
"extends": "flarum-tsconfig",
"include": ["src/**/*", "../vendor/flarum/core/js/dist-typings/@types/**/*"],
"compilerOptions": {
"declarationDir": "./dist-typings",
"paths": {
"flarum/*": ["../vendor/flarum/core/js/dist-typings/*"]
}
}
}