-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Google feedback on TS 4.7-beta #48848
Comments
I think that the
error message was introduced by #44578, and it seems to be a breaking change that @amcasey and I saw a bit on internal codebases. I think that you can instead write
@amcasey and I ran into this on internal codebases as well... Kind of painful.
This is one of the biggest ones I think we have seen manual intervention with. How are you feeling about these updates right now? |
Is there something I should be watching out for w.r.t. the aforementioned |
I think the specific thing I found was an instance of trying to stub/mock out a custom |
Thanks for the hint. We'll check if this is something we can add automatically to the affected code.
Null check improvements seen generally nice to have to me. We haven't dug deeper into the errors, yet. It's hard to say for me at the moment if this helped catch real errors. I'll try to remember to report back when I know more. Some notes, though:
Similar to what Daniel said, we see this error in stubs/mocks. E.g.:
I think those failures are expected. |
Okay, yeah, that's going to happen any time a built-in function becomes more permissive because function parameters are contravariant. You generally want the error because it alerts you to the fact that your monkey-patched stub doesn't handle the new case(s). That being said, I thought |
You're right that |
Ah, see, I thought |
So for the example that you gave function extract<T>(obj: {}, other: Partial<T>) {
(obj as T);
// ^^^^^^^^
// Conversion of type '{}' to type 'T' may be a mistake because neither type sufficiently overlaps with the other. If this was intentional, convert the expression to 'unknown' first.
// 'T' could be instantiated with an arbitrary type which could be unrelated to '{}'.(2352)
} @weswigham's PR at #48861 should allow casting between |
Thanks, @DanielRosenwasser. I didn't realize this is unintentional. I've looked at a handful of the other errors that are probably caused by "Type Parameter No Longer Assignable to |
We imported 4.7-rc. As expected, we no longer see the breakages caused by "Type Parameter No Longer Assignable to We don't see any other major changes compared to the beta. Though we did find that the |
This GitHub issue contains feedback on the TS 4.7-beta release from the team that is responsible for keeping Google's internal software working with the latest version of TypeScript.
Executive summary
Impact summary
{}
instrictNullChecks
keyof T
The Announced column indicates whether we were able to connect the observed change with a section in the TS4.7-beta announcement.
The following sections give more detailed explanations of the changes listed above.
Changes which were announced
Type Parameter No Longer Assignable to
{}
instrictNullChecks
We see type errors similar to the ones mentioned in the release announcement.
We're looking into adding
extends object
to generic type parameters where possible and casts toany
to silence the error everywhere else.lib/d.ts changes
We support the typing improvements. Generally it's clear what's changing.
We observed the following breakdown within this category:
fetch
now also acceptsURL
in addition toRequestInfo
for the first parameterAbortSignal
has additional membersreason
andthrowIfAborted
ImageData
has additional membercolorSpace
HTMLVideoElement
has additional membersrequestVideoFrameCallback
andcancelVideoFrameCallback
Object.assign
now rejects null/undefined for the first parameterObject.freeze
has an additional overload, which causes some type errors like:We expect to add casts to
any
to silence the error and apply proper fixes over time.Changes which were not announced
TS2774 & TS2801 now fire for secondary conditions in if statements
This wasn't specifically mentioned in the release announcement, but looks like a decent improvement. Example:
We expect to add casts to
any
to silence the error and apply proper fixes over time.TS2731 now fires for
keyof T
This wasn't specifically mentioned in the release announcement, but looks like a decent improvement. Example:
We expect to add casts to
any
to silence the error and apply proper fixes over time.The text was updated successfully, but these errors were encountered: