fix(types): fixed Fixtures type to disambiguite between intersected mapped types
This commit is contained in:
parent
f3ae940684
commit
c4fd612bc3
4
packages/playwright/types/test.d.ts
vendored
4
packages/playwright/types/test.d.ts
vendored
|
|
@ -5663,9 +5663,9 @@ export type Fixtures<T extends KeyValue = {}, W extends KeyValue = {}, PT extend
|
|||
} & {
|
||||
[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 }];
|
||||
} & {
|
||||
[K in keyof W]?: [WorkerFixtureValue<W[K], W & PW>, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
|
||||
[K in keyof W as Exclude<K, keyof PW | keyof PT>]?: [WorkerFixtureValue<W[K], W & PW>, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
|
||||
} & {
|
||||
[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 }];
|
||||
[K in keyof T as Exclude<K, keyof PW | 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 }];
|
||||
};
|
||||
|
||||
type BrowserName = 'chromium' | 'firefox' | 'webkit';
|
||||
|
|
|
|||
|
|
@ -17,3 +17,66 @@ test('sample test', async ({ page, plugin }) => {
|
|||
// @ts-expect-error
|
||||
await expect(page).toContainText(123);
|
||||
});
|
||||
|
||||
test1.extend({
|
||||
page: async ({ page }) => {
|
||||
type IsPage = (typeof page) extends Page ? true : never;
|
||||
const isPage: IsPage = true;
|
||||
},
|
||||
});
|
||||
|
||||
test1.extend<{ myFixture: (arg: number) => void }>({
|
||||
page: async ({ page }) => {
|
||||
type IsPage = (typeof page) extends Page ? true : never;
|
||||
const isPage: IsPage = true;
|
||||
},
|
||||
});
|
||||
|
||||
test1.extend({
|
||||
myFixture: async ({ page }) => {
|
||||
type IsPage = (typeof page) extends Page ? true : never;
|
||||
const isPage: IsPage = true;
|
||||
}
|
||||
});
|
||||
|
||||
test1.extend<{ myFixture: (arg: number) => void }>({
|
||||
myFixture: async ({ page }) => {
|
||||
type IsPage = (typeof page) extends Page ? true : never;
|
||||
const isPage: IsPage = true;
|
||||
}
|
||||
});
|
||||
|
||||
test1.extend({
|
||||
page: async ({ page }) => {
|
||||
type IsPage = (typeof page) extends Page ? true : never;
|
||||
const isPage: IsPage = true;
|
||||
},
|
||||
myFixture: async ({ page }) => {
|
||||
type IsPage = (typeof page) extends Page ? true : never;
|
||||
const isPage: IsPage = true;
|
||||
}
|
||||
});
|
||||
|
||||
test1.extend<{ myFixture: (arg: number) => void }>({
|
||||
page: async ({ page }) => {
|
||||
type IsPage = (typeof page) extends Page ? true : never;
|
||||
const isPage: IsPage = true;
|
||||
},
|
||||
myFixture: async ({ page }) => {
|
||||
type IsPage = (typeof page) extends Page ? true : never;
|
||||
const isPage: IsPage = true;
|
||||
}
|
||||
});
|
||||
|
||||
test1.extend<{ myFixture: (arg: number) => void }>({
|
||||
// @ts-expect-error
|
||||
myFixture: (arg: number) => {},
|
||||
});
|
||||
|
||||
test1.extend<{ myFixture: (arg: number) => void }>({
|
||||
myFixture: async (_, use) => {
|
||||
use((arg: number) => {});
|
||||
// @ts-expect-error
|
||||
use((arg: string) => {});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
4
utils/generate_types/overrides-test.d.ts
vendored
4
utils/generate_types/overrides-test.d.ts
vendored
|
|
@ -178,9 +178,9 @@ export type Fixtures<T extends KeyValue = {}, W extends KeyValue = {}, PT extend
|
|||
} & {
|
||||
[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 }];
|
||||
} & {
|
||||
[K in keyof W]?: [WorkerFixtureValue<W[K], W & PW>, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
|
||||
[K in keyof W as Exclude<K, keyof PW | keyof PT>]?: [WorkerFixtureValue<W[K], W & PW>, { scope: 'worker', auto?: boolean, option?: boolean, timeout?: number | undefined, title?: string, box?: boolean }];
|
||||
} & {
|
||||
[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 }];
|
||||
[K in keyof T as Exclude<K, keyof PW | 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 }];
|
||||
};
|
||||
|
||||
type BrowserName = 'chromium' | 'firefox' | 'webkit';
|
||||
|
|
|
|||
Loading…
Reference in a new issue