-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Labels
P3-collecting-feedbackopen-to-a-pull-requestThe feature request looks good, we are open to reviewing a PRThe feature request looks good, we are open to reviewing a PR
Description
Version
1.49.0
Steps to reproduce
page.on('console', (consoleMessage) => {
if (consoleMessage.type() === 'warn') {
Expected behavior
The code above should throw a TypeScript error.
Actual behavior
The code above does not throw a TypeScript error.
Additional context
I see this in the Playwright types:
/**
* One of the following values: `'log'`, `'debug'`, `'info'`, `'error'`, `'warning'`, `'dir'`, `'dirxml'`, `'table'`,
* `'trace'`, `'clear'`, `'startGroup'`, `'startGroupCollapsed'`, `'endGroup'`, `'assert'`, `'profile'`,
* `'profileEnd'`, `'count'`, `'timeEnd'`.
*/
type(): string;
This is silly. Instead of putting those values into a comment, make that the actual (union) type, so that everyone gets the benefit of stricter types. Because we've been incorrectly looking for "warn" (instead of "warning") in our code, we've been missing test failures for a while now.
Environment
System:
OS: Windows 11 10.0.26100
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Memory: 2.81 GB / 15.71 GB
Binaries:
Node: 22.14.0 - C:\Program Files\Node.js\node.EXE
npm: 11.1.0 - C:\Program Files\Node.js\npm.CMD
IDEs:
VSCode: 1.100.2 - C:\Users\kgetz\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
Languages:
Bash: 5.2.26 - C:\Users\kgetz\AppData\Local\Programs\Git\usr\bin\bash.EXE
Copilot
Metadata
Metadata
Assignees
Labels
P3-collecting-feedbackopen-to-a-pull-requestThe feature request looks good, we are open to reviewing a PRThe feature request looks good, we are open to reviewing a PR
Activity
fix: use literals as a return value in ConsoleMessage's type (microso…
fix: use literals as a return value in ConsoleMessage's type (#36036) (…