Closed ericmatthys closed 11 months ago
I can't repro this. Please follow the BUG template to provide exact steps I can follow to reproduce this, starting with npm init playwright@latest
@ericmatthys Check your local paths. Playwright have internally renamed some packages (#26946) and if you have the same folders/files as Playwright's, TypeScript might erroneously resolve those against your local packages instead of node_module's ones.
Simple way to reproduce the issue:
node_modules/@playwright/test/index.d.ts
'playwright/test'
:export * from 'playwright/test';
export { default } from 'playwright/test';
In my case, I actually have a local file playwright/test.ts
and when I click on those namespaces, my IDE opens my local file, not Playwright's types
It seems to be an issue with how pnpm is installing dependencies in a monorepo using symlinks, despite TS being configured to preserve sym links. Adding playwright
as an explicit dependency as well as @playwright/test
fixes the TS errors, despite playwright
already being a dependency of @playwright/test
. I'll take a closer look at what is happening there.
More context: https://github.com/orgs/pnpm/discussions/5535
Adding public-hoist-pattern[]=playwright
to .npmrc
is another way of fixing the issue
My solution to this is to use paths in tsconfig.json
:
"paths": {
"playwright/test": ["node_modules/playwright/test"]
}
since I am not using pnpm
More context: https://github.com/orgs/pnpm/discussions/5535
Adding
public-hoist-pattern[]=playwright
to.npmrc
is another way of fixing the issue
Stumbled upon this issue recently, I'm using pnpm. For me, the fix was to actually put
public-hoist-pattern[]=playwright*
in the .npmrc. The playwright-core
package needs to be present as well.
System info
Source code
Expected
With 1.37.1, these imports are valid.
Actual
TS2614: Module "@playwright/test" has no exported member TestInfo .
TS2614: Module "@playwright/test" has no exported member PlaywrightTestConfig .
I didn't see anything in the release notes that indicates that this is an expected breaking change.