Version
1.52.0
Steps to reproduce
- Clone this minimal repo minimal-reproduction
- Run 'npm install'
- Open playwright.config.ts
- Observe the TS error in the line:
workers: process.env.CI ? 1 : undefined
- Remove "exactOptionalPropertyTypes": true from tsconfig.json and the error disappears
Expected behavior
This should be valid workers: process.env.CI ? 1 : undefined
Because workers is optional, assigning undefined should be fine under typical TypeScript behavior.
Actual behavior
TypeScript throws the following error:
Type 'number | undefined' is not assignable to type 'string | number'.
Type 'undefined' is not assignable to type 'string | number'.ts(2769)
This only happens when exactOptionalPropertyTypes: true is enabled.
Additional context
-
This issue stems from the exactOptionalPropertyTypes flag introduced in TypeScript 4.4, which enforces stricter typing around optional fields.
-
Playwright's current typings assume the looser default behavior (optional? implicitly allows undefined), which breaks in stricter TS configs.
-
This type of issue can silently discourage teams from enabling stricter type checking, which is increasingly standard in modern TypeScript codebases.
-
Other config fields may also be affected — it’s worth auditing all optional fields for compatibility with exactOptionalPropertyTypes.
Environment
System:
OS: Linux 6.11 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12500H
Memory: 5.12 GB / 15.32 GB
Container: Yes
Binaries:
Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
pnpm: 10.4.0 - ~/.nvm/versions/node/v22.14.0/bin/pnpm
Languages:
Bash: 5.2.21 - /usr/bin/bash
npmPackages:
@playwright/test: ^1.52.0 => 1.52.0
Version
1.52.0
Steps to reproduce
workers: process.env.CI ? 1 : undefinedExpected behavior
This should be valid
workers: process.env.CI ? 1 : undefinedBecause workers is optional, assigning undefined should be fine under typical TypeScript behavior.
Actual behavior
TypeScript throws the following error:
This only happens when exactOptionalPropertyTypes: true is enabled.
Additional context
This issue stems from the exactOptionalPropertyTypes flag introduced in TypeScript 4.4, which enforces stricter typing around optional fields.
Playwright's current typings assume the looser default behavior (optional? implicitly allows undefined), which breaks in stricter TS configs.
This type of issue can silently discourage teams from enabling stricter type checking, which is increasingly standard in modern TypeScript codebases.
Other config fields may also be affected — it’s worth auditing all optional fields for compatibility with exactOptionalPropertyTypes.
Environment
System: OS: Linux 6.11 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat) CPU: (16) x64 12th Gen Intel(R) Core(TM) i5-12500H Memory: 5.12 GB / 15.32 GB Container: Yes Binaries: Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm pnpm: 10.4.0 - ~/.nvm/versions/node/v22.14.0/bin/pnpm Languages: Bash: 5.2.21 - /usr/bin/bash npmPackages: @playwright/test: ^1.52.0 => 1.52.0