fix(types): do not use import('electron') (#5572)

This commit is contained in:
Dmitry Gozman 2021-02-23 18:48:34 -08:00 committed by GitHub
parent 8f79b8c175
commit 5cb914b2fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 11 deletions

View File

@ -20,3 +20,5 @@ export * from './types/types';
export const chromium: types.BrowserType<types.ChromiumBrowser>; export const chromium: types.BrowserType<types.ChromiumBrowser>;
export const firefox: types.BrowserType<types.FirefoxBrowser>; export const firefox: types.BrowserType<types.FirefoxBrowser>;
export const webkit: types.BrowserType<types.WebKitBrowser>; export const webkit: types.BrowserType<types.WebKitBrowser>;
export const _electron: types.Electron;
export const _android: types.Android;

View File

@ -108,7 +108,7 @@ function test_typescript_types {
"playwright-webkit" "playwright-webkit"
do do
echo "Checking types of ${PKG_NAME}" echo "Checking types of ${PKG_NAME}"
echo "import { Page } from '${PKG_NAME}';" > "${PKG_NAME}.ts" && tsc "${PKG_NAME}.ts" echo "import { Page } from '${PKG_NAME}';" > "${PKG_NAME}.ts" && npx -p typescript@3.7.5 tsc "${PKG_NAME}.ts"
done; done;
echo "${FUNCNAME[0]} success" echo "${FUNCNAME[0]} success"
@ -351,7 +351,7 @@ function test_electron_types {
echo "import { Page, electron, ElectronApplication, Electron } from 'playwright-electron';" > "test.ts" echo "import { Page, electron, ElectronApplication, Electron } from 'playwright-electron';" > "test.ts"
echo "Running tsc" echo "Running tsc"
npx tsc "test.ts" npx -p typescript@3.7.5 tsc "test.ts"
echo "${FUNCNAME[0]} success" echo "${FUNCNAME[0]} success"
} }
@ -365,7 +365,7 @@ function test_android_types {
echo "import { AndroidDevice, android, AndroidWebView, Page } from 'playwright-android';" > "test.ts" echo "import { AndroidDevice, android, AndroidWebView, Page } from 'playwright-android';" > "test.ts"
echo "Running tsc" echo "Running tsc"
npx tsc "test.ts" npx -p typescript@3.7.5 tsc "test.ts"
echo "${FUNCNAME[0]} success" echo "${FUNCNAME[0]} success"
} }

8
types/types.d.ts vendored
View File

@ -7095,8 +7095,8 @@ export interface ElectronApplication {
* @param pageFunction Function to be evaluated in the worker context. * @param pageFunction Function to be evaluated in the worker context.
* @param arg Optional argument to pass to `pageFunction`. * @param arg Optional argument to pass to `pageFunction`.
*/ */
evaluate<R, Arg>(pageFunction: PageFunctionOn<typeof import('electron'), Arg, R>, arg: Arg): Promise<R>; evaluate<R, Arg>(pageFunction: PageFunctionOn<any, Arg, R>, arg: Arg): Promise<R>;
evaluate<R>(pageFunction: PageFunctionOn<typeof import('electron'), void, R>, arg?: any): Promise<R>; evaluate<R>(pageFunction: PageFunctionOn<any, void, R>, arg?: any): Promise<R>;
/** /**
* Returns the return value of `pageFunction` as a [JSHandle]. * Returns the return value of `pageFunction` as a [JSHandle].
@ -7117,8 +7117,8 @@ export interface ElectronApplication {
* @param pageFunction Function to be evaluated in the worker context. * @param pageFunction Function to be evaluated in the worker context.
* @param arg * @param arg
*/ */
evaluateHandle<R, Arg>(pageFunction: PageFunctionOn<typeof import('electron'), Arg, R>, arg: Arg): Promise<SmartHandle<R>>; evaluateHandle<R, Arg>(pageFunction: PageFunctionOn<any, Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
evaluateHandle<R>(pageFunction: PageFunctionOn<typeof import('electron'), void, R>, arg?: any): Promise<SmartHandle<R>>; evaluateHandle<R>(pageFunction: PageFunctionOn<any, void, R>, arg?: any): Promise<SmartHandle<R>>;
/** /**
* This event is issued when the application closes. * This event is issued when the application closes.
*/ */

View File

@ -223,11 +223,11 @@ export const selectors: Selectors;
export const devices: Devices & DeviceDescriptor[]; export const devices: Devices & DeviceDescriptor[];
export interface ElectronApplication { export interface ElectronApplication {
evaluate<R, Arg>(pageFunction: PageFunctionOn<typeof import('electron'), Arg, R>, arg: Arg): Promise<R>; evaluate<R, Arg>(pageFunction: PageFunctionOn<any, Arg, R>, arg: Arg): Promise<R>;
evaluate<R>(pageFunction: PageFunctionOn<typeof import('electron'), void, R>, arg?: any): Promise<R>; evaluate<R>(pageFunction: PageFunctionOn<any, void, R>, arg?: any): Promise<R>;
evaluateHandle<R, Arg>(pageFunction: PageFunctionOn<typeof import('electron'), Arg, R>, arg: Arg): Promise<SmartHandle<R>>; evaluateHandle<R, Arg>(pageFunction: PageFunctionOn<any, Arg, R>, arg: Arg): Promise<SmartHandle<R>>;
evaluateHandle<R>(pageFunction: PageFunctionOn<typeof import('electron'), void, R>, arg?: any): Promise<SmartHandle<R>>; evaluateHandle<R>(pageFunction: PageFunctionOn<any, void, R>, arg?: any): Promise<SmartHandle<R>>;
} }
export type AndroidElementInfo = { export type AndroidElementInfo = {