PolymerLabs / arcs

Arcs
BSD 3-Clause "New" or "Revised" License
56 stars 35 forks source link

Silence type errors reported by TS 4.2. #7072

Closed copybara-service[bot] closed 3 years ago

copybara-service[bot] commented 3 years ago

Silence type errors reported by TS 4.2.

I expect to submit a CL to update google3 to TS 4.2 before 2021-04-01. This CL needs to submitted to prevent or fix compile breakages that will happen at that time.

TS 4.2 changes type checking and builtin type definitions in various ways that cause it to report errors that TS 4.1 did not.

This change silences new error messages by making the smallest reasonable change that will have no effect on the output JS.

Most often this means casting the problem value to a custom alias for any named AnyDuringTs42Migration. This is guaranteed to leave the behavior of the code unchanged. After the migration to TS 4.2 is complete, the owning teams should work to remove these casts by improving the accuracy of the type declarations in their code.

If you already see there is a better way fix this code, please do that in a followup CL and test it against the upgrade CL listed at the top of go/ts42upgrade to confirm that you've really fixed it.

NOTE: Just removing the AnyDuringTs41Migration cast won't trigger any errors while google3 is still on TS 4.1, but it will require us to make this change again before we can upgrade to TS 4.2.

Please do not ask the author of this CL to make any changes to it unless you believe your code will actually be broken by this change. We need to change hundreds of files, and cannot realistically give them individual attention.

See also b/181591179 and go/ts42upgrade