However, in the above example, both FruitEater
s and ColorConsumer
s should be able to take the string "orange"
, and return either a number
or a string
.
In TypeScript 3.3, this is no longer an error.
In TypeScript 3.3, the parameters of these signatures are intersected together to create a new signature.
This new behavior only kicks in when at most one type in the union has multiple overloads, and at most one type in the union has a generic signature. That means methods on number[] | string[]
like map
(which is generic) still won’t be callable.
On the other hand, methods like forEach
will now be callable, but under there may be some issues.
This is still strictly more capable in TypeScript 3.3, and adding an explicit type annotation will work.
TypeScript 2.7 also introduced --watch
mode builds via a new incremental “builder” API. In a similar vein, the entire idea is that this mode only re-checks and re-emits changed files or files whose dependencies might impact type-checking. You can think of this as optimizing intra-project builds.
Prior to 3.3, building composite projects using --build --watch
actually didn’t use this incremental file watching infrastructure. An update in one project under --build --watch
mode would force a full build of that project, rather than determining which files within that project were affected.
In TypeScript 3.3, --build
mode’s --watch
flag does leverage incremental file watching as well. That can mean signficantly faster builds under --build --watch
. In our testing, this functionality has resulted in a reduction of 50% to 75% in build times of the original times. to see specific numbers, but we believe most composite project users will see significant wins here.