| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) test this |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the abridged perf test suite on this PR at 39326d7. You can monitor the build here. Update: The results are in! |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 39326d7. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 39326d7. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based community code test suite on this PR at 39326d7. You can monitor the build here. Update: The results are in! |
Sorry, something went wrong.
|
Anders Hejlsberg (@ahejlsberg) Comparison Report - main..refs/pull/49119/merge [async]1 of 1 projects failed to build with the old tsc /mnt/ts_downloads/async/tsconfig.json
|
Sorry, something went wrong.
|
Anders Hejlsberg (@ahejlsberg) Comparison Report - main..49119
System
Hosts
Scenarios
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sorry, something went wrong.
|
TypeScript Bot (@typescript-bot) test this |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the abridged perf test suite on this PR at 986963c. You can monitor the build here. Update: The results are in! |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the parallelized Definitely Typed test suite on this PR at 986963c. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the diff-based community code test suite on this PR at 986963c. You can monitor the build here. |
Sorry, something went wrong.
|
Heya Anders Hejlsberg (@ahejlsberg), I've started to run the extended test suite on this PR at 986963c. You can monitor the build here. |
Sorry, something went wrong.
|
Anders Hejlsberg (@ahejlsberg) Comparison Report - main..49119
System
Hosts
Scenarios
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sorry, something went wrong.
|
Ilya Solovyov (@user) test this inline |
Sorry, something went wrong.
|
Is there a reason why this narrowing wasn't implemented for typeof x === "undefined" the way it was for x === undefined? See this SO question |
Sorry, something went wrong.
|
I feel like that's an oversight and probably deserves its own issue. (But, I'm not Anders 😄) |
Sorry, something went wrong.
|
Joe Calzaretta (@jcalz) what you reported here, in your last comment, was just fixed 2 days ago in #52456 |
Sorry, something went wrong.
|
It seems that in the examples in the main message in the function f5<T> the type parameter T is missing in a couple of places: function f5<T>(x: T) {
...
if (x !== undefined && x !== null) {
x; // {} -- should be T & {}
}
else {
x; // T
}
if (x != undefined) {
x; // {} -- should be NonNullable<T>
}
else {
x; // T
}
if (x != null) {
x; // {} -- should be NonNullable<T>
}
else {
x; // T
}
}But this is clear from the context and will not confuse anyone too much, I think. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR introduces a number of changes affecting control flow analysis of truthy, equality, and typeof checks involving type unknown and unconstrained type variables in --strictNullChecks mode. Key to these changes is the fact that {}, the empty object type literal, is a supertype of all types except null and undefined. Thus, {} | null | undefined is effectively equivalent to unknown, and for an arbitrary type T, the intersection T & {} represents the non-nullable form of T.
The PR introduces the following new behaviors:
Some examples:
Note the manner in which types are properly inferred, combined, and reduced in the ensureNotXXX functions. This contrasts with the NonNullable<T> conditional type provided in lib.d.ts, which unfortunately combines and reduces poorly. For example, NonNullable<NonNullable<T>> doesn't inherently reduce to NonNullable<T>, sometimes leading to needlessly complex types. For this and other reasons we intend to investigate switching NonNullable<T> to be an alias for T & {}.
For backwards compatibility, special exceptions to the T & {} type reduction rules existing for intersections written explicitly as string & {}, number & {}, and bigint & {} (as opposed to created through instantiation of a generic type T & {}). These types are used in a few frameworks (e.g. react and csstype) to construct types that permit any string, number, or bigint, but has statement completion hints for common literal values. For example:
The special string & {} type prevents subtype reduction from taking place in the union type, thus preserving the literal types, but otherwise any string value is assignable to the type.
This PR reinstatates #48366 (which was removed from 4.7 due to concerns over breaking changes).
Fixes #23368.
Fixes #31908.
Fixes #32347.
Fixes #43997.
Fixes #44446.
Fixes #48048.
Fixes #48468.
Fixes #48691.
Fixes #49005.
Fixes #49191.