Description
After upgrading from v0.6.4 to v0.6.5, TypeScript reports a type error when passing @playwright/test's BrowserContext to defineNetworkFixture.
Steps to reproduce
import { test as base } from '@playwright/test'
import { defineNetworkFixture } from '@msw/playwright'
const test = base.extend({
network: async ({ context }, use) => {
// TS2322: Type 'BrowserContext' (from @playwright/test) is not assignable
// to type 'BrowserContext' (inlined in @msw/playwright's bundled types)
const network = defineNetworkFixture({ context })
await network.enable()
await use(network)
await network.disable()
},
})
Root cause
The v0.6.5 release (#43) changed the exports conditions. As a result, build/index.d.mts now inlines all of playwright-core's type definitions (~23,000 lines, 1.6MB file).
The source code correctly imports BrowserContext from @playwright/test:
// src/fixture.ts
import type { BrowserContext } from '@playwright/test'
But after bundling with tsdown, this becomes a locally declared BrowserContext interface inside the .d.mts file, rather than a reference to the user's installed @playwright/test types. TypeScript treats these as distinct types, causing the mismatch.
Expected behavior
@playwright/test (or playwright-core) should be marked as external in the tsdown bundle configuration so that the type definition emits an import statement rather than inlining the types.
Environment
@msw/playwright: 0.6.5
@playwright/test: 1.58.2
- TypeScript: 5.8.2
Description
After upgrading from v0.6.4 to v0.6.5, TypeScript reports a type error when passing
@playwright/test'sBrowserContexttodefineNetworkFixture.Steps to reproduce
Root cause
The v0.6.5 release (#43) changed the
exportsconditions. As a result,build/index.d.mtsnow inlines all ofplaywright-core's type definitions (~23,000 lines, 1.6MB file).The source code correctly imports
BrowserContextfrom@playwright/test:But after bundling with tsdown, this becomes a locally declared
BrowserContextinterface inside the.d.mtsfile, rather than a reference to the user's installed@playwright/testtypes. TypeScript treats these as distinct types, causing the mismatch.Expected behavior
@playwright/test(orplaywright-core) should be marked as external in the tsdown bundle configuration so that the type definition emits animportstatement rather than inlining the types.Environment
@msw/playwright: 0.6.5@playwright/test: 1.58.2