Skip to content

Commit 30684a7

Browse files
authored
cherry-pick(#32066): fix(types): revert type changes made to support TS 5.5 (#32080)
Regressed in #31532. The TS5.5 changes broke chaining of `extend`s where the first `extend` did not specify any type arguments. Fixes #32056.
1 parent 5e68061 commit 30684a7

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

packages/playwright/types/test.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4815,9 +4815,9 @@ export type Fixtures<T extends KeyValue = {}, W extends KeyValue = {}, PT extend
48154815
} & {
48164816
[K in keyof PT]?: TestFixtureValue<PT[K], T & W & PT & PW> | [TestFixtureValue<PT[K], T & W & PT & PW>, { scope: 'test', timeout?: number | undefined, title?: string, box?: boolean }];
48174817
} & {
4818-
[K in Exclude<keyof W, keyof PW>]?: [WorkerFixtureValue<W[K], W & PW>, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
4818+
[K in keyof W]?: [WorkerFixtureValue<W[K], W & PW>, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
48194819
} & {
4820-
[K in Exclude<keyof T, keyof PT>]?: TestFixtureValue<T[K], T & W & PT & PW> | [TestFixtureValue<T[K], T & W & PT & PW>, { scope?: 'test', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
4820+
[K in keyof T]?: TestFixtureValue<T[K], T & W & PT & PW> | [TestFixtureValue<T[K], T & W & PT & PW>, { scope?: 'test', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
48214821
};
48224822

48234823
type BrowserName = 'chromium' | 'firefox' | 'webkit';

tests/library/global-fetch.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { expect, playwrightTest as base } from '../config/browserTest';
2121
import { kTargetClosedErrorMessage } from 'tests/config/errors';
2222

2323
const it = base.extend({
24-
context: async () => {
24+
context: async ({}, use) => {
2525
throw new Error('global fetch tests should not use context');
2626
}
2727
});

tests/playwright-test/types.spec.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { test, expect } from './playwright-test-fixtures';
1919
test('should check types of fixtures', async ({ runTSC }) => {
2020
const result = await runTSC({
2121
'helper.ts': `
22-
import { test as base, expect } from '@playwright/test';
22+
import { test as base, expect, Page } from '@playwright/test';
2323
export type MyOptions = { foo: string, bar: number };
2424
export const test = base.extend<{ foo: string }, { bar: number }>({
2525
foo: 'foo',
@@ -71,7 +71,7 @@ test('should check types of fixtures', async ({ runTSC }) => {
7171
// @ts-expect-error
7272
baz: true,
7373
});
74-
const fail9 = test.extend<{ foo: string }>({
74+
const fail9 = test.extend({
7575
foo: [ async ({}, use) => {
7676
await use('foo');
7777
// @ts-expect-error
@@ -100,7 +100,21 @@ test('should check types of fixtures', async ({ runTSC }) => {
100100
return y;
101101
});
102102
},
103-
})
103+
});
104+
105+
const chain1 = base.extend({
106+
page: async ({ page }, use) => {
107+
await use(page);
108+
},
109+
});
110+
const chain2 = chain1.extend<{ pageAsUser: Page }>({
111+
pageAsUser: async ({ page }, use) => {
112+
// @ts-expect-error
113+
const x: number = page;
114+
// @ts-expect-error
115+
await use(x);
116+
},
117+
});
104118
`,
105119
'playwright.config.ts': `
106120
import { MyOptions } from './helper';

utils/generate_types/overrides-test.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ export type Fixtures<T extends KeyValue = {}, W extends KeyValue = {}, PT extend
144144
} & {
145145
[K in keyof PT]?: TestFixtureValue<PT[K], T & W & PT & PW> | [TestFixtureValue<PT[K], T & W & PT & PW>, { scope: 'test', timeout?: number | undefined, title?: string, box?: boolean }];
146146
} & {
147-
[K in Exclude<keyof W, keyof PW>]?: [WorkerFixtureValue<W[K], W & PW>, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
147+
[K in keyof W]?: [WorkerFixtureValue<W[K], W & PW>, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
148148
} & {
149-
[K in Exclude<keyof T, keyof PT>]?: TestFixtureValue<T[K], T & W & PT & PW> | [TestFixtureValue<T[K], T & W & PT & PW>, { scope?: 'test', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
149+
[K in keyof T]?: TestFixtureValue<T[K], T & W & PT & PW> | [TestFixtureValue<T[K], T & W & PT & PW>, { scope?: 'test', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
150150
};
151151

152152
type BrowserName = 'chromium' | 'firefox' | 'webkit';

0 commit comments

Comments
 (0)