You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PR #32504 introduces an overridable location parameter for the test.step API, to be included in Playwright 1.48.0.
When testing the new test.step API using build 1.48.0-alpha-2024-09-18, I noticed that the Location type used by the location parameter is not exported from @playwright/test. This results in TypeScript throwing error TS2353: Object literal may only specify known properties, and 'file' does not exist in type 'Location'. during type checking, as TypeScript assumes that Location refers to Location type from lib-dom, rather than Playwright's Location interface.
To reproduce the error, write a Playwright Test script overriding the location parameter when calling the test.step API:
import{test}from'@playwright/test';test.describe('Playwright Test',()=>{test('should allow for the location to be overridden',async()=>{awaittest.step('my step',async()=>{},{location: {file: 'my-file.ts',line: 42,column: 13}});});});
Add a tsconfig.json file to your project, for example:
spec/repro.spec.ts:25:27 - error TS2353: Object literal may only specify known properties, and 'file' does not exist in type 'Location'.
25 { location: { file: 'my-file.ts', line: 42, column: 13 } }
Expected behavior
The Location type should be exported alongside other public interfaces of @playwright/test.
For example, it should be possible to do the following:
Version
1.48.0-alpha-2024-09-18
Steps to reproduce
PR #32504 introduces an overridable
location
parameter for thetest.step
API, to be included in Playwright 1.48.0.When testing the new
test.step
API using build1.48.0-alpha-2024-09-18
, I noticed that theLocation
type used by thelocation
parameter is not exported from@playwright/test
. This results in TypeScript throwing errorTS2353: Object literal may only specify known properties, and 'file' does not exist in type 'Location'.
during type checking, as TypeScript assumes thatLocation
refers toLocation
type fromlib-dom
, rather than Playwright'sLocation
interface.To reproduce the error, write a Playwright Test script overriding the
location
parameter when calling thetest.step
API:Add a
tsconfig.json
file to your project, for example:Run the TypeScript type checker:
Observe the below error in the output:
Expected behavior
The
Location
type should be exported alongside other public interfaces of@playwright/test
.For example, it should be possible to do the following:
I'd suggest moving the definition of Playwright's
Location
fromtestReporter.d.ts
toplaywright/types/test.d.ts
since it's now part of the public API.Actual behavior
The
Location
is not exportedAdditional context
See #32504 and the corresponding feature request #30160 for more context
CC @dgozman, @osohyun0224, @vitalets, @WestonThayer
Environment
The text was updated successfully, but these errors were encountered: