Description
This GitHub issue contains feedback on the TS 4.6-beta release from the team
that is responsible for keeping Google's internal software working with the
latest version of TypeScript.
Executive summary
- Some changes to our TypeScript code are required to make it compile with TS
4.6. - Detail sections below explain the changes to our code we expect to make to
unblock the upgrade.
Impact summary
Change description | Announced | Libraries affected |
---|---|---|
lib/d.ts Changes | no | 0.0357% |
Object Rests Drop Unspreadable Members from Generic Objects | yes | 0.0011% |
Syntax and Binding Errors in JavaScript | - | 0.000% |
Unclassified | - | 0.037% |
The Announced column indicates whether we were able to connect the observed
change with a section in the
TS4.6-beta announcement.
The following sections give more detailed explanations of the changes listed
above.
Changes which were announced
lib/d.ts Changes
This change was not announced but also expected.
We support the typing improvements. Generally it's clear what's changing.
Our fix will be inserting type casts to silence the errors in existing code.
We observed the following breakdown within this category:
- AriaMixin interface properties made nullable: 88.09%
- 'VisibilityState' (got renamed to 'DocumentVisibilityState'): 7.14%
- Stricter type of 'StructuredSerializeOptions' interface property: 0.79%
- 'NumberFormatOptions' removes the 'currencyDisplay' property: 0.79%
- Stricter type of 'CanvasCompositing' interface property: 3.17%
Object Rests Drop Unspreadable Members from Generic Objects
Dropping unspreadable members breaks code in google which destructures this
.
When destructuring this
using a ...rest
element, unspreadable and non-public
members are now dropped. This causes breakages in google where the rest element
is being cast because neither type sufficiently overlaps with the other.
Example breakage:
override getTabModelState(): TabModel {
const {resultsObs, ...tab} = this;
return tab as TabModel;
}
We may potentially fix this by changing user code or work around by casting to
unknown first.
Syntax and Binding Errors in JavaScript
Google did not have any JavaScript failures related to the new JavaScript syntax
and binding errors, because our build infrastructure is configured such that it
does not pass JavaScript files through TypeScript.
Changes that are skipped
- Some pending Pull Requests that add ES2021 types are not getting included in
the TS 4.6 release. For example,
feat(46907): AddIntl.ListFormat
type declarations #47254