Skip to content

fix: use literals as a return value in ConsoleMessage's type (#36036) #36568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 7, 2025

Conversation

ReaZzy
Copy link
Contributor

@ReaZzy ReaZzy commented Jul 5, 2025

Updated the ConsoleMessage type definition to use literals as return values instead of string. By explicitly specifying the possible values.

Fixes #36036.

This comment has been minimized.

Copy link
Contributor

@dgozman dgozman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR!

@@ -1157,7 +1157,27 @@ Browser:
ConsoleMessage:
type: mixin
properties:
type: string
type:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to change protocol.yml for this. It will entail extra work for all playwright language ports. Let's keep it as a string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted the change

@@ -17,6 +17,7 @@
import type * as js from './javascript';
import type { Page } from './page';
import type { ConsoleMessageLocation } from './types';
import type * as api from '../../types/types';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing client types on the server is prohibited. Let's keep it a string here.

@@ -139,7 +139,7 @@ The text of the console message.

## method: ConsoleMessage.type
* since: v1.8
- returns: <[string]>
- returns: <["log"|"debug"|"info"|"error"|"warning"|"dir"|"dirxml"|"table"|"trace"|"clear"|"startGroup"|"startGroupCollapsed"|"endGroup"|"assert"|"profile"|"profileEnd"|"count"|"timeEnd"]>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- returns: <["log"|"debug"|"info"|"error"|"warning"|"dir"|"dirxml"|"table"|"trace"|"clear"|"startGroup"|"startGroupCollapsed"|"endGroup"|"assert"|"profile"|"profileEnd"|"count"|"timeEnd"]>
- returns: <[ConsoleMessageType]<"log"|"debug"|"info"|"error"|"warning"|"dir"|"dirxml"|"table"|"trace"|"clear"|"startGroup"|"startGroupCollapsed"|"endGroup"|"assert"|"profile"|"profileEnd"|"count"|"timeEnd">>

Copy link
Contributor

github-actions bot commented Jul 7, 2025

Test results for "tests 1"

9 flaky ⚠️ [chromium-library] › library/chromium/tracing.spec.ts:49:3 › should run with custom categories if provided @chromium-ubuntu-22.04-node18
⚠️ [chromium-library] › library/chromium/tracing.spec.ts:49:3 › should run with custom categories if provided @chromium-ubuntu-22.04-node20
⚠️ [chromium-library] › library/chromium/tracing.spec.ts:49:3 › should run with custom categories if provided @chromium-ubuntu-22.04-node24
⚠️ [firefox-library] › library/inspector/cli-codegen-1.spec.ts:1087:7 › cli codegen record › should not throw csp directive violation errors @firefox-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @ubuntu-latest-node18-1
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @ubuntu-latest-node20-1
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @ubuntu-latest-node22-1
⚠️ [webkit-page] › page/page-screenshot.spec.ts:345:5 › page screenshot › should work while navigating @webkit-ubuntu-22.04-node18
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all @windows-latest-node18-1

47103 passed, 980 skipped
✔️✔️✔️

Merge workflow run.

Copy link
Contributor

@dgozman dgozman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, merging in. Thank you for the contribution!

@dgozman dgozman merged commit bbf198a into microsoft:main Jul 7, 2025
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: ConsoleMessage type is kind of inadequate
2 participants