Why `rslib` doesn't see types from DefinitelyTyped package?

3 weeks ago 25
ARTICLE AD BOX

To build my lib I use Rslib. In my code I use DefinitelyTyped package @types/firefox-webext-browser. During build Rslib doesn't see types coming from this package:

error [tsc] src/Communication.ts:2:29 - error TS2503: Cannot find namespace 'browser'. 2 export type MessageSender = browser.runtime.MessageSender;

There isn't any fancy in my configs rslib.config.ts:

import { pluginReact } from '@rsbuild/plugin-react'; import { defineConfig } from '@rslib/core'; export default defineConfig( { plugins: [pluginReact()], source: { tsconfigPath: "./tsconfig.json", entry: { index: ['./src/**'], }, }, lib: [ { bundle: false, dts: true, format: 'esm' }, ], output: { cleanDistPath: true, distPath: "./build/", target: 'web', }, }); { "compilerOptions": { "lib": ["DOM", "ES2022"], "jsx": "react-jsx", "module": "es2022", "skipLibCheck": true, "isolatedModules": true, "resolveJsonModule": true, "moduleResolution": "bundler", "useDefineForClassFields": true, "rootDir": "./src" }, "include": ["src/**/*"] }

SWC overrides somehow my config (in particular types property)?

Read Entire Article