Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(ct): dedupe json object (#22138)

Sander789d8b24c0c6
diff --git a/packages/playwright-ct-react/hooks.d.ts b/packages/playwright-ct-react/hooks.d.ts
index 31cbda4c23..cc2b660587 100644
--- a/packages/playwright-ct-react/hooks.d.ts
+++ b/packages/playwright-ct-react/hooks.d.ts
@@ -14,10 +14,8 @@
* limitations under the License.
*/
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
+import type { JsonObject } from '@playwright/test/types/component';
+
export declare function beforeMount<HooksConfig extends JsonObject>(
callback: (params: { hooksConfig?: HooksConfig; App: () => JSX.Element }) => Promise<void | JSX.Element>
): void;
diff --git a/packages/playwright-ct-react/index.d.ts b/packages/playwright-ct-react/index.d.ts
index 63327ee138..75a7a097d5 100644
--- a/packages/playwright-ct-react/index.d.ts
+++ b/packages/playwright-ct-react/index.d.ts
@@ -23,6 +23,7 @@ import type {
PlaywrightWorkerOptions,
Locator,
} from '@playwright/test';
+import type { JsonObject } from '@playwright/test/types/component';
import type { InlineConfig } from 'vite';
export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig<T, W>, 'use'> & {
@@ -34,11 +35,6 @@ export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig
};
};
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
-
export interface MountOptions<HooksConfig extends JsonObject> {
hooksConfig?: HooksConfig;
}
diff --git a/packages/playwright-ct-react17/hooks.d.ts b/packages/playwright-ct-react17/hooks.d.ts
index 31cbda4c23..cc2b660587 100644
--- a/packages/playwright-ct-react17/hooks.d.ts
+++ b/packages/playwright-ct-react17/hooks.d.ts
@@ -14,10 +14,8 @@
* limitations under the License.
*/
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
+import type { JsonObject } from '@playwright/test/types/component';
+
export declare function beforeMount<HooksConfig extends JsonObject>(
callback: (params: { hooksConfig?: HooksConfig; App: () => JSX.Element }) => Promise<void | JSX.Element>
): void;
diff --git a/packages/playwright-ct-react17/index.d.ts b/packages/playwright-ct-react17/index.d.ts
index 63327ee138..75a7a097d5 100644
--- a/packages/playwright-ct-react17/index.d.ts
+++ b/packages/playwright-ct-react17/index.d.ts
@@ -23,6 +23,7 @@ import type {
PlaywrightWorkerOptions,
Locator,
} from '@playwright/test';
+import type { JsonObject } from '@playwright/test/types/component';
import type { InlineConfig } from 'vite';
export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig<T, W>, 'use'> & {
@@ -34,11 +35,6 @@ export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig
};
};
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
-
export interface MountOptions<HooksConfig extends JsonObject> {
hooksConfig?: HooksConfig;
}
diff --git a/packages/playwright-ct-solid/hooks.d.ts b/packages/playwright-ct-solid/hooks.d.ts
index 048978cd53..398a2390bb 100644
--- a/packages/playwright-ct-solid/hooks.d.ts
+++ b/packages/playwright-ct-solid/hooks.d.ts
@@ -15,11 +15,8 @@
*/
import { JSXElement } from "solid-js";
+import type { JsonObject } from '@playwright/test/types/component';
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
export declare function beforeMount<HooksConfig extends JsonObject>(
callback: (params: { hooksConfig?: HooksConfig, App: () => JSXElement }) => Promise<void | JSXElement>
): void;
diff --git a/packages/playwright-ct-solid/index.d.ts b/packages/playwright-ct-solid/index.d.ts
index 63327ee138..75a7a097d5 100644
--- a/packages/playwright-ct-solid/index.d.ts
+++ b/packages/playwright-ct-solid/index.d.ts
@@ -23,6 +23,7 @@ import type {
PlaywrightWorkerOptions,
Locator,
} from '@playwright/test';
+import type { JsonObject } from '@playwright/test/types/component';
import type { InlineConfig } from 'vite';
export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig<T, W>, 'use'> & {
@@ -34,11 +35,6 @@ export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig
};
};
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
-
export interface MountOptions<HooksConfig extends JsonObject> {
hooksConfig?: HooksConfig;
}
diff --git a/packages/playwright-ct-svelte/hooks.d.ts b/packages/playwright-ct-svelte/hooks.d.ts
index 1c2107325b..46ab2f64e2 100644
--- a/packages/playwright-ct-svelte/hooks.d.ts
+++ b/packages/playwright-ct-svelte/hooks.d.ts
@@ -15,11 +15,8 @@
*/
import type { SvelteComponent } from 'svelte';
+import type { JsonObject } from '@playwright/test/types/component';
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
export declare function beforeMount<HooksConfig extends JsonObject>(
callback: (params: { hooksConfig?: HooksConfig }) => Promise<void>
): void;
diff --git a/packages/playwright-ct-svelte/index.d.ts b/packages/playwright-ct-svelte/index.d.ts
index b879c1eed2..37863a0a91 100644
--- a/packages/playwright-ct-svelte/index.d.ts
+++ b/packages/playwright-ct-svelte/index.d.ts
@@ -23,6 +23,7 @@ import type {
PlaywrightWorkerOptions,
Locator,
} from '@playwright/test';
+import type { JsonObject } from '@playwright/test/types/component';
import type { InlineConfig } from 'vite';
import type { SvelteComponent, ComponentProps } from 'svelte/types/runtime';
@@ -35,11 +36,6 @@ export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig
};
};
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
-
type Slot = string | string[];
export interface MountOptions<
diff --git a/packages/playwright-ct-vue/hooks.d.ts b/packages/playwright-ct-vue/hooks.d.ts
index 3503b0fa37..d92b34b10f 100644
--- a/packages/playwright-ct-vue/hooks.d.ts
+++ b/packages/playwright-ct-vue/hooks.d.ts
@@ -15,11 +15,8 @@
*/
import type { App, ComponentPublicInstance } from 'vue';
+import type { JsonObject } from '@playwright/test/types/component';
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
export declare function beforeMount<HooksConfig extends JsonObject>(
callback: (params: { app: App; hooksConfig?: HooksConfig }) => Promise<void>
): void;
diff --git a/packages/playwright-ct-vue/index.d.ts b/packages/playwright-ct-vue/index.d.ts
index e3cd55a7f1..f8636036d7 100644
--- a/packages/playwright-ct-vue/index.d.ts
+++ b/packages/playwright-ct-vue/index.d.ts
@@ -23,6 +23,7 @@ import type {
PlaywrightWorkerOptions,
Locator,
} from '@playwright/test';
+import type { JsonObject } from '@playwright/test/types/component';
import type { InlineConfig } from 'vite';
export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig<T, W>, 'use'> & {
@@ -34,11 +35,6 @@ export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig
};
};
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
-
type Slot = string | string[];
export interface MountOptions<
diff --git a/packages/playwright-ct-vue2/hooks.d.ts b/packages/playwright-ct-vue2/hooks.d.ts
index 7c422f0595..55104c9d3e 100644
--- a/packages/playwright-ct-vue2/hooks.d.ts
+++ b/packages/playwright-ct-vue2/hooks.d.ts
@@ -16,11 +16,7 @@
import { ComponentOptions } from 'vue';
import { CombinedVueInstance, Vue, VueConstructor } from 'vue/types/vue';
-
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
+import type { JsonObject } from '@playwright/test/types/component';
export declare function beforeMount<HooksConfig extends JsonObject>(
callback: (params: {
diff --git a/packages/playwright-ct-vue2/index.d.ts b/packages/playwright-ct-vue2/index.d.ts
index 5f338cef3b..3ea059a04a 100644
--- a/packages/playwright-ct-vue2/index.d.ts
+++ b/packages/playwright-ct-vue2/index.d.ts
@@ -23,6 +23,7 @@ import type {
PlaywrightWorkerOptions,
Locator,
} from '@playwright/test';
+import type { JsonObject } from '@playwright/test/types/component';
import type { InlineConfig } from 'vite';
export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig<T, W>, 'use'> & {
@@ -34,11 +35,6 @@ export type PlaywrightTestConfig<T = {}, W = {}> = Omit<BasePlaywrightTestConfig
};
};
-type JsonPrimitive = string | number | boolean | null;
-type JsonValue = JsonPrimitive | JsonObject | JsonArray;
-type JsonArray = JsonValue[];
-type JsonObject = { [Key in string]?: JsonValue };
-
type Slot = string | string[];
export interface MountOptions<
diff --git a/packages/playwright-test/types/component.d.ts b/packages/playwright-test/types/component.d.ts
index 88c33fb669..74787f1af3 100644
--- a/packages/playwright-test/types/component.d.ts
+++ b/packages/playwright-test/types/component.d.ts
@@ -14,6 +14,11 @@
* limitations under the License.
*/
+type JsonPrimitive = string | number | boolean | null;
+type JsonValue = JsonPrimitive | JsonObject | JsonArray;
+type JsonArray = JsonValue[];
+export type JsonObject = { [Key in string]?: JsonValue };
+
export type JsxComponent = {
kind: 'jsx',
type: string,