mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-01 08:34:02 +03:00
fix(esm): fix TS type check with NodeNext mode (#16340)
This commit is contained in:
parent
5dea817355
commit
e725b5f8a9
2
packages/playwright-core/types/structs.d.ts
vendored
2
packages/playwright-core/types/structs.d.ts
vendored
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { JSHandle, ElementHandle, Frame, Page, BrowserContext } from 'playwright-core';
|
||||
import { JSHandle, ElementHandle, Frame, Page, BrowserContext } from './types';
|
||||
|
||||
/**
|
||||
* Can be converted to JSON
|
||||
|
4
packages/playwright-core/types/types.d.ts
vendored
4
packages/playwright-core/types/types.d.ts
vendored
@ -14,12 +14,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Protocol } from 'playwright-core/types/protocol';
|
||||
import { ChildProcess } from 'child_process';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Readable } from 'stream';
|
||||
import { ReadStream } from 'fs';
|
||||
import { Serializable, EvaluationArgument, PageFunction, PageFunctionOn, SmartHandle, ElementHandleForTag, BindingSource } from 'playwright-core/types/structs';
|
||||
import { Protocol } from './protocol';
|
||||
import { Serializable, EvaluationArgument, PageFunction, PageFunctionOn, SmartHandle, ElementHandleForTag, BindingSource } from './structs';
|
||||
|
||||
type PageWaitForSelectorOptionsNotHidden = PageWaitForSelectorOptions & {
|
||||
state?: 'visible'|'attached';
|
||||
|
4
packages/playwright-test/types/test.d.ts
vendored
4
packages/playwright-test/types/test.d.ts
vendored
@ -3042,8 +3042,8 @@ export interface PlaywrightTestArgs {
|
||||
export type PlaywrightTestProject<TestArgs = {}, WorkerArgs = {}> = Project<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>;
|
||||
export type PlaywrightTestConfig<TestArgs = {}, WorkerArgs = {}> = Config<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>;
|
||||
|
||||
import type * as expectType from '@playwright/test/types/expect-types';
|
||||
import type { Suite } from '@playwright/test/types/testReporter';
|
||||
import type * as expectType from './expect-types';
|
||||
import type { Suite } from './testReporter';
|
||||
|
||||
type AsymmetricMatcher = Record<string, any>;
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { FullConfig, FullProject, TestStatus, TestError, Metadata } from '@playwright/test';
|
||||
export type { FullConfig, TestStatus, TestError } from '@playwright/test';
|
||||
import type { FullConfig, FullProject, TestStatus, TestError, Metadata } from './test';
|
||||
export type { FullConfig, TestStatus, TestError } from './test';
|
||||
|
||||
/**
|
||||
* `Suite` is a group of tests. All tests in Playwright Test form the following hierarchy:
|
||||
|
@ -35,3 +35,26 @@ test('typescript types should work', async ({ exec, tsc, writeFiles }) => {
|
||||
|
||||
await tsc('playwright-test-types.ts');
|
||||
});
|
||||
|
||||
test('typescript types should work with module: NodeNext', async ({ exec, tsc, writeFiles }) => {
|
||||
// module: NodeNext got added in TypeScript 4.7
|
||||
await exec('npm i --foreground-scripts typescript@4.7 @types/node@18');
|
||||
const libraryPackages = [
|
||||
'playwright',
|
||||
'playwright-core',
|
||||
'playwright-firefox',
|
||||
'playwright-webkit',
|
||||
'playwright-chromium',
|
||||
];
|
||||
await exec('npm i @playwright/test', ...libraryPackages, { env: { PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1' } });
|
||||
|
||||
for (const libraryPackage of libraryPackages) {
|
||||
const filename = libraryPackage + '.ts';
|
||||
await writeFiles({
|
||||
[filename]: `import { Page } from '${libraryPackage}';`,
|
||||
});
|
||||
await exec('npx', '-p', 'typescript@4.7', 'tsc', '--module nodenext', filename);
|
||||
}
|
||||
|
||||
await exec('npx', '-p', 'typescript@4.7', 'tsc', '--module nodenext', 'playwright-test-types.ts');
|
||||
});
|
||||
|
4
utils/generate_types/overrides-test.d.ts
vendored
4
utils/generate_types/overrides-test.d.ts
vendored
@ -252,8 +252,8 @@ export interface PlaywrightTestArgs {
|
||||
export type PlaywrightTestProject<TestArgs = {}, WorkerArgs = {}> = Project<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>;
|
||||
export type PlaywrightTestConfig<TestArgs = {}, WorkerArgs = {}> = Config<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>;
|
||||
|
||||
import type * as expectType from '@playwright/test/types/expect-types';
|
||||
import type { Suite } from '@playwright/test/types/testReporter';
|
||||
import type * as expectType from './expect-types';
|
||||
import type { Suite } from './testReporter';
|
||||
|
||||
type AsymmetricMatcher = Record<string, any>;
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { FullConfig, FullProject, TestStatus, TestError, Metadata } from '@playwright/test';
|
||||
export type { FullConfig, TestStatus, TestError } from '@playwright/test';
|
||||
import type { FullConfig, FullProject, TestStatus, TestError, Metadata } from './test';
|
||||
export type { FullConfig, TestStatus, TestError } from './test';
|
||||
|
||||
export interface Suite {
|
||||
project(): FullProject | undefined;
|
||||
|
4
utils/generate_types/overrides.d.ts
vendored
4
utils/generate_types/overrides.d.ts
vendored
@ -13,12 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Protocol } from 'playwright-core/types/protocol';
|
||||
import { ChildProcess } from 'child_process';
|
||||
import { EventEmitter } from 'events';
|
||||
import { Readable } from 'stream';
|
||||
import { ReadStream } from 'fs';
|
||||
import { Serializable, EvaluationArgument, PageFunction, PageFunctionOn, SmartHandle, ElementHandleForTag, BindingSource } from 'playwright-core/types/structs';
|
||||
import { Protocol } from './protocol';
|
||||
import { Serializable, EvaluationArgument, PageFunction, PageFunctionOn, SmartHandle, ElementHandleForTag, BindingSource } from './structs';
|
||||
|
||||
type PageWaitForSelectorOptionsNotHidden = PageWaitForSelectorOptions & {
|
||||
state?: 'visible'|'attached';
|
||||
|
Loading…
Reference in New Issue
Block a user