You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are in the process of evaluating the impact of upgrading to 4.9 on our codebase. Here are some preliminary findings.
This is shaping up to be a low impact release: just <1% of packages have new build errors with 4.9.
#
Change
Affects
Release notes
Packages affected
1
Declare no longer appears on type in declaration files
Declaration Files
Not Announced
~30%
2
NaN comparison
Type checking
Announced
<0.3%
3
In operator is more strict about RHS operand being object
Type checking
Announced
<0.5%
4
Intersection between type parameter and undefined
Type checking
Not Announced
<0.3%
5
Generic type parameter loses defined constraint
Type checking
Not Announced
<0.15%
Declare no longer appears on type in declaration files
This is a benign change to declarations (the declare keyword is no longer generated in d.ts files for type aliases). While this change does not cause issues, it did cause a lot of noise when trying to evaluate if there were meaningful declaration changes.
NaN comparison
TypeScript now warns on comparison with NaN. This causes two packages to break in what looks like missed bugs in code.
In operator is more strict about RHS operand being object
This caused several packages to break. Some errors seem to be good, such as requiring type parameters to extend object instead of being unconstrained.
We did find a related issue, reported as #51007 where x instanceof Object does not narrow x to be an object.
When we use a conditional type to test if a type parameter extends another type, the original constraint of the type parameter is lost:
exporttypeTypeA={A: 'A',B: 'B',}exporttypeTypeB={A: 'A',B: 'B',C: 'C',}// Fails to index TypeA with TtypeR<TextendskeyofTypeA>=TextendskeyofTypeB ? [TypeA[T],TypeB[T]] : never
Some methods in classes have moved in the JS output. 4.9 respects original order so this seems intentional. Sample
Some declaration maps have changed.
Some property aliases in destructuring have been removed from declarations. (Seems like a good change and a continuation of work in 4.8)
One complex mapped and conditional type has lost its ability to be directly asserted as another complex mapped and conditional type. While this is a breaking change, the types are complex enough I would not have expected them to be assignable or assertable anyway.
The text was updated successfully, but these errors were encountered:
In operator is more strict about RHS operand being object Type checking Not Announced
This was announced in the blog post (last paragraph before NaN)
TypeScript 4.9 also tightens up a few checks around how in is used, ensuring that the left side is assignable to the type string | number | symbol, and the right side is assignable to object.
In operator is more strict about RHS operand being object Type checking Not Announced
This was announced in the blog post (last paragraph before NaN)
TypeScript 4.9 also tightens up a few checks around how in is used, ensuring that the left side is assignable to the type string | number | symbol, and the right side is assignable to object.
We are in the process of evaluating the impact of upgrading to 4.9 on our codebase. Here are some preliminary findings.
This is shaping up to be a low impact release: just <1% of packages have new build errors with 4.9.
Declare no longer appears on type in declaration files
This is a benign change to declarations (the
declare
keyword is no longer generated in d.ts files for type aliases). While this change does not cause issues, it did cause a lot of noise when trying to evaluate if there were meaningful declaration changes.NaN
comparisonTypeScript now warns on comparison with
NaN
. This causes two packages to break in what looks like missed bugs in code.In operator is more strict about RHS operand being object
This caused several packages to break. Some errors seem to be good, such as requiring type parameters to extend object instead of being unconstrained.
We did find a related issue, reported as #51007 where
x instanceof Object
does not narrow x to be an object.Intersection between type parameter and undefined
Intersection between a type parameter and undefined no longer reduces to never.
This seems like a bug, reported as #51041
Generic type parameter loses defined constraint
When we use a conditional type to test if a type parameter extends another type, the original constraint of the type parameter is lost:
This seems like a bug, reported as #51009
Other changes
There were some other minor changes:
The text was updated successfully, but these errors were encountered: