-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Some Playwright types now reported as any
after upgrading to 5.7.2
#60619
Comments
bisects to #52095 , minimal-ish repro case: TS playground I already have a somewhat good grasp of the issue. I'll write more about it tomorrow though and continue the investigation. |
I don't understand why I'll dive deeper into it later but in the meantime I've also created a different repro case that doesn't include that |
@Andarist The By the way, I once tried to replace |
Ah ye, I already figured this part out (side note - you don't have any type tests in Playwright for this scenario, no test fail after replacing I'm not yet sure where it breaks internally but, in general, "not a type" isn't something greatly supported by TS. I put together some notes~ on various ways to do it in this TS playground. Ultimately, only your strategy gives the desired results here.
You are on the right track here when it comes to the root cause. The problem is that your With my change the compiler uses all property types that could come out of deferred instantiations at this position. So it uses function types from all of those 4 mapped types and they are just not compatible with each other. That's how we end up with implicit anys. To be fair, even before TS 5.7 the inference didn't quite work OK in your case (the contextual parameter types did though): TS playground. I somewhat doubt you care about it, when defining extra fixtures it's advised to use type params explicitly here instead of relying on the inference. It would certainly be great to make it work though. Luckily-ish since TS 5.6 (since this PR) we can leverage filtering mapped types to disambiguite slightly between those mapped types: TS playground And when it comes to the inference, the situation could be improved by this PR. We can see some improvements already on the TS playground using a TS build from that PR: TS playground. Based on those findings, I need to take a look at what happens with context-sensitive functions there because they seem to brak this inference. Note that on the TS playground above I also replaced multiple TLDR: I created a PR with a fix for this in Playwright here |
π Search Terms
I manually scrolled through all issues reported since the release of 5.7.2.
π Version & Regression Information
β― Playground Link
https://github.com/mrmckeb/pw-repro
π» Code
Minimal repro available here:
https://github.com/mrmckeb/pw-repro
The Playwright team are also able to reproduce:
microsoft/playwright#33763
The affected code (from the repro) is:
π Actual behavior
Types that were previously available are now typed as
any
. JSDoc continues to work as expected.π Expected behavior
Types behave as they did in TypeScript 5.6.3.
Additional information about the issue
We found this issue when upgrading from 5.6.3 to 5.7.2. I couldn't find a related issue here, so raised it at the Playwright repo to at least verify that they could reproduce and that they didn't think it was an issue with their types.
The Playwright team also confirmed that they have 71 new errors across 41 files when moving to TypeScript 5.7.2.
The text was updated successfully, but these errors were encountered: