From 2bb024cc2914cf1e55ab8f798f4c590fceef389c Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 5 Jul 2024 16:07:44 +0200 Subject: [PATCH] fixes typing issue --- packages/playwright/types/test.d.ts | 4 ++-- tests/playwright-test/types.spec.ts | 6 ++++++ utils/generate_types/overrides-test.d.ts | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts index 5a18eded3f..d9d740f000 100644 --- a/packages/playwright/types/test.d.ts +++ b/packages/playwright/types/test.d.ts @@ -4815,9 +4815,9 @@ export type Fixtures | [TestFixtureValue, { scope: 'test', timeout?: number | undefined, title?: string, box?: boolean }]; } & { - [K in keyof W]?: [WorkerFixtureValue, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }]; + [K in Exclude]?: [WorkerFixtureValue, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }]; } & { - [K in keyof T]?: TestFixtureValue | [TestFixtureValue, { scope?: 'test', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }]; + [K in Exclude]?: TestFixtureValue | [TestFixtureValue, { scope?: 'test', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }]; }; type BrowserName = 'chromium' | 'firefox' | 'webkit'; diff --git a/tests/playwright-test/types.spec.ts b/tests/playwright-test/types.spec.ts index ba26912c71..da8d88a38b 100644 --- a/tests/playwright-test/types.spec.ts +++ b/tests/playwright-test/types.spec.ts @@ -71,6 +71,12 @@ test('should check types of fixtures', async ({ runTSC }) => { // @ts-expect-error baz: true, }); + const fail9 = test.extend<{ foo: string }>({ + foo: [ async ({}, use) => { + await use('foo'); + // @ts-expect-error + }, { scope: 'test', auto: true } ], + }); const fail10 = test.extend<{}, {}>({ // @ts-expect-error bar: [ async ({}, use) => { diff --git a/utils/generate_types/overrides-test.d.ts b/utils/generate_types/overrides-test.d.ts index 80880f71a7..67b355b79f 100644 --- a/utils/generate_types/overrides-test.d.ts +++ b/utils/generate_types/overrides-test.d.ts @@ -144,9 +144,9 @@ export type Fixtures | [TestFixtureValue, { scope: 'test', timeout?: number | undefined, title?: string, box?: boolean }]; } & { - [K in keyof W]?: [WorkerFixtureValue, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }]; + [K in Exclude]?: [WorkerFixtureValue, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }]; } & { - [K in keyof T]?: TestFixtureValue | [TestFixtureValue, { scope?: 'test', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }]; + [K in Exclude]?: TestFixtureValue | [TestFixtureValue, { scope?: 'test', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }]; }; type BrowserName = 'chromium' | 'firefox' | 'webkit';