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 TypeScript 5.3 on our codebase. Here are some preliminary findings up to version 5.3.0-dev.20230928.
This is shaping up to be a low impact release. The following table lists changes that affected our codebase:
(🟢 - Good breaking change, 🔴 - Bad breaking change)
#
Change
Affects
Release notes
Packages affected
Reported As
1
Unrelated interface causes assignability to change 🔴
Removing Keyed (unused) bellow causes R to change. The error also sometimes appears and sometimes it does not in VS Code.
export{}interfaceMap<V>extendsCollection<V>{flatMap<VM>(): Map<VM>;}interfaceCollection<V>{value: V;// sprinkle some covariancemap: Map<V>;concat(): Collection<unknown>;flatMap(): Collection<V>;flatMap<VM>(): Collection<VM>;}// Comment out and it works like in 5.2interfaceKeyedextendsCollection<number>{concat(): Keyed;}typeR=Map<never>extendsCollection<infer V> ? V : "NO";constr=null!asR;constt: "NO"=r;
Both 5.2 and 5.3 don't really seem to do a good job here, R should probably be never (and in 5.3 removing flatMap(): Collection<V>; will make R never)
2. Source map improvements
Some mapping in sourcemaps appear to better point back to the source code (they previously did not include the original line, column and file).
Seems like a net improvement but given the huge diff it's difficult to assess if any other changes occurred.
3. Negative number literals are not allowed
Internal tooling created negative numeric literals, which are not supported (they should be expressed as a minus unary operator and a positive numeric literal). TypeScript 5.3 now asserts that numeric literals are always positive.
4. Error on duplicate computed properties
Typescript now correctly detects more duplicate computed properties. This caught several places in our code base where we had duplicate properties in our object literals.
constc={V: "B"}asconst;leto={[c.V]: 1,[c.V]: 1,// No error in 5.2}
Typescript now correctly uses guard(o) === false in CFA. This surfaced several places in our code where even though the type guard was being used, it's effect on the type of the symbol was basically being ignored.
6. New error on super.field
TypeScript now correctly errors on access to fields on super. We currently use a field in the base class to represent what is actually a method, we were ignoring the previous error on the override:
classB{on!: ()=>void;}classDextendsB{//@ts-ignoreon(){super.on();// new error}}
7. Bug fix to assignability of Record<string, unknown> in mapped type
5.3 includes a bug fix where a nested property of type Record<string, unknown> that passes through a mapped type becomes assignable to an object with required properties.
This caused some existing code to fail, but definitely a good catch.
exporttypeId<T>={[PinkeyofT]: Id<T[P]>;};exporttypeData={action: {// Has to be nestedcommit: {category: stringgroup: number;};}}declareletx: Id<{action: {commit: Record<string,unknown>}}>letu: Id<Data>=x;// should be an error is in 5.3u.action.commit=x.action.commit;// should be an error is in 5.3
By @molisani & @dragomirtitian
We are in the process of evaluating the impact of upgrading to TypeScript 5.3 on our codebase. Here are some preliminary findings up to version
5.3.0-dev.20230928
.This is shaping up to be a low impact release. The following table lists changes that affected our codebase:
(🟢 - Good breaking change, 🔴 - Bad breaking change)
guard(o) === false
🟢super.field
🟢Record<string, unknown>
in mapped type 🟢1. Unrelated interface causes assignability to change
Reported as #56099
Removing
Keyed
(unused) bellow causesR
to change. The error also sometimes appears and sometimes it does not in VS Code.Both 5.2 and 5.3 don't really seem to do a good job here,
R
should probably benever
(and in 5.3 removingflatMap(): Collection<V>;
will makeR
never)2. Source map improvements
Some mapping in sourcemaps appear to better point back to the source code (they previously did not include the original line, column and file).
Seems like a net improvement but given the huge diff it's difficult to assess if any other changes occurred.
3. Negative number literals are not allowed
Internal tooling created negative numeric literals, which are not supported (they should be expressed as a minus unary operator and a positive numeric literal). TypeScript 5.3 now asserts that numeric literals are always positive.
4. Error on duplicate computed properties
Typescript now correctly detects more duplicate computed properties. This caught several places in our code base where we had duplicate properties in our object literals.
Playground Link 5.2
Playground Link 5.3 beta
5. TS now understands
guard(o) === false
Typescript now correctly uses
guard(o) === false
in CFA. This surfaced several places in our code where even though the type guard was being used, it's effect on the type of the symbol was basically being ignored.6. New error on
super.field
TypeScript now correctly errors on access to fields on
super
. We currently use a field in the base class to represent what is actually a method, we were ignoring the previous error on the override:Playground Link 5.2
Playground Link 5.3 beta
7. Bug fix to assignability of
Record<string, unknown>
in mapped type5.3 includes a bug fix where a nested property of type
Record<string, unknown>
that passes through a mapped type becomes assignable to an object with required properties.This caused some existing code to fail, but definitely a good catch.
Playground Link 5.2
Playground Link 5.3 beta
8. Set accessor parameter name in d.ts from JS is preserved
This one came up only in internal tests. The original name of the setter parameter is now preserved where the name was previously generated.
Playground Link 5.2 Playground Link 5.3 beta
The text was updated successfully, but these errors were encountered: