Bring back return type narrowing + fixes
Fixes #33014. Fixes #33912.
This PR brings back conditional and indexed access return type narrowing from #56941, but with a few updates. The main motivation behind those updates is described in https://gist.github.com/gabritto/b6ebd5f9fc2bb3cfc305027609e66bca, but to put it shortly, type narrowing very often cannot distinguish between two non-primitive types, and since return type narrowing depends on type narrowing to work, it often didn't.
Update 1: non-primitive restriction
To deal with those problematic type narrowing scenarios, the first update is to disallow narrowing of conditional return types that attempt to distinguish between two non-primitive types. So this example will not work:
type QuickPickReturn<T extends QuickPickOptions> =
T extends { canSelectMultiple: true } ? string[] :
T extends { canSelectMultiple: false } ? string :
never;
type QuickPickOptions = {
prompt: string;
items: string[];
canSelectMultiple: true;
} | {
prompt: string;
items: string[];
canSelectMultiple: false;
}
function showQuickPick<T extends QuickPickOptions>(options: T): QuickPickReturn<T> {
if (options.canSelectMultiple) {
return options.items; // Error
}
return options.items[0]; // Error
}
That's because the conditional return type QuickPickReturn has one branch with type { canSelectMultiple: true }, which is non-primitive,
and another branch with type { canSelectMultiple: false }, which is also non-primitive.
However, the following will work:
type QuickPickOptions<T extends boolean> = {
prompt: string;
items: string[];
canSelectMultiple: T;
};
type QuickPickReturn<T extends boolean> =
T extends true ? string[] :
T extends false ? string :
never;
function showQuickPick<T extends boolean>(options: QuickPickOptions<T>): QuickPickReturn<T> {
if (options.canSelectMultiple) {
return options.items;
}
return options.items[0];
}
type QuickPickOptions = {
prompt: string;
items: string[];
};
type QuickPickReturn<T extends string | QuickPickOptions> =
T extends string ? string :
T extends QuickPickOptions ? string[] :
never;
function showQuickPick<T extends string | QuickPickOptions>(optionsOrItem: T): QuickPickReturn<T> {
if (typeof optionsOrItem === "string") {
return optionsOrItem;
}
return optionsOrItem.items;
}
Distinguishing between two primitive types or between a primitive and non-primitive type in the conditional type's branches is allowed.
Update 2: type parameter embedding
We can now detect that a type parameter is a candidate for being used in return type narrowing (i.e. it's a narrowable type parameter) in
cases where the type parameter is indirectly used as a type of a parameter or property.
Before, only this type of usage of T in a parameter type annotation would be recognized:
type PickNumberRet<T> =
T extends true ? 1 :
T extends false ? 2 :
never;
function pickNumber<T extends boolean>(b: T): PickNumberRet<T> {
return b ? 1 : 2;
}
Now, the following also work:
type PickNumberRet<T> =
T extends true ? 1 :
T extends false ? 2 :
never;
function pickNumber<T extends boolean>({ b }: { b: T }): PickNumberRet<T> {
return b ? 1 : 2;
}
function pickNumber<T extends boolean>(opts: { b: T }): PickNumberRet<T> {
return opts.b ? 1 : 2;
}
Combined with the non-primitive restriction mentioned above, this enables users to place narrowable type parameters inside object types
at the exact property that is used for narrowing, so instead of writing this: function fun<T extends { prop: true } | { prop: false }>(param: T): ...,
users can write this: function fun<T extends true | false>(param: { prop: T }): ....
Note that the analysis done to decide if a type parameter is used the parameter in a way that allows it to be narrowed is a syntactical one. We want to avoid resolving and inspecting actual types during the analysis, because a lot of types are lazy in some sense, and we don't want this analysis to cause unintended side effects, e.g. circularity errors. But this means that any usage of a type parameter that requires semantically resolving types to validate it is not going to work.
For a more complete list of what's currently supported here in terms of usages of type parameters, see test tests\cases\compiler\dependentReturnType11.ts.
Update 3: relax extends type restriction
This is a small improvement unrelated to the previous updates. In the original PR, this was disallowed because we required that a conditional return type's extends types be identical to the types in the type parameter constraint:
interface Dog {
name: string;
bark(): string;
}
type NormalizedRet<T> =
T extends {} ? T :
T extends null | undefined ? undefined :
never;
function normalizeDog<T extends Dog | undefined | null>(dog: T): NormalizedRet<T> {
if (dog == undefined) {
return undefined; // Originally an error
}
return dog; // Originally an error
}
Note that in NormalizedRet, the first branch's extends type is {}, not Dog, so this wasn't allowed because those types are not identical.
With this PR, we only require that a type in the constraint is assignable to the extends type, i.e. that Dog is assignable to {},
so the code above is now allowed for return type narrowing.
@typescript-bot pack this
Starting jobs; this comment will be updated as builds start and complete.
| Command | Status | Results |
|---|---|---|
pack this |
✅ Started | ✅ Results |
@typescript-bot test it
Starting jobs; this comment will be updated as builds start and complete.
| Command | Status | Results |
|---|---|---|
test top400 |
✅ Started | ✅ Results |
user test this |
✅ Started | ✅ Results |
run dt |
✅ Started | ✅ Results |
perf test this faster |
✅ Started | 👀 Results |
Hey @gabritto, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:
{
"devDependencies": {
"typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/164947/artifacts?artifactName=tgz&fileId=D8EFF21205462B38E502A6643448F71CEACCECECE108A3D1D461EC8F7E9FF1E702&fileName=/typescript-5.9.0-insiders.20250320.tgz"
}
}
and then running npm install.
There is also a playground for this build and an npm module you can use via "typescript": "npm:@typescript-deploys/[email protected]".;
Hey @gabritto, the results of running the DT tests are ready.
Everything looks the same!
@gabritto Here are the results of running the user tests with tsc comparing main and refs/pull/61359/merge:
Everything looks good!
@gabritto The results of the perf run you requested are in!
Here they are:
tsc
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Compiler-Unions - node (v18.15.0, x64) | ||||||
| Errors | 34 | 34 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 62,390 | 62,390 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 50,395 | 50,395 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 194,123k (± 0.96%) | 193,824k (± 0.80%) | ~ | 193,125k | 196,973k | p=0.230 n=6 |
| Parse Time | 1.31s (± 0.79%) | 1.31s (± 0.75%) | ~ | 1.30s | 1.33s | p=0.591 n=6 |
| Bind Time | 0.73s | 0.73s | ~ | ~ | ~ | p=1.000 n=6 |
| Check Time | 9.74s (± 0.43%) | 9.74s (± 0.18%) | ~ | 9.72s | 9.76s | p=0.935 n=6 |
| Emit Time | 2.74s (± 1.10%) | 2.72s (± 0.72%) | ~ | 2.70s | 2.75s | p=0.258 n=6 |
| Total Time | 14.53s (± 0.31%) | 14.51s (± 0.17%) | ~ | 14.46s | 14.53s | p=0.259 n=6 |
| angular-1 - node (v18.15.0, x64) | ||||||
| Errors | 56 | 56 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 948,670 | 948,670 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 410,947 | 410,947 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 1,224,316k (± 0.00%) | 1,225,575k (± 0.00%) | +1,259k (+ 0.10%) | 1,225,549k | 1,225,617k | p=0.005 n=6 |
| Parse Time | 6.64s (± 0.98%) | 6.66s (± 0.59%) | ~ | 6.60s | 6.70s | p=0.810 n=6 |
| Bind Time | 1.88s (± 0.58%) | 1.88s (± 0.78%) | ~ | 1.86s | 1.90s | p=0.866 n=6 |
| Check Time | 31.88s (± 0.31%) | 31.99s (± 0.24%) | +0.11s (+ 0.33%) | 31.92s | 32.10s | p=0.037 n=6 |
| Emit Time | 15.23s (± 0.21%) | 15.25s (± 0.55%) | ~ | 15.11s | 15.33s | p=0.468 n=6 |
| Total Time | 55.63s (± 0.25%) | 55.77s (± 0.28%) | ~ | 55.58s | 56.01s | p=0.127 n=6 |
| mui-docs - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 2,363,778 | 2,363,778 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 846,530 | 846,530 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 2,133,827k (± 0.01%) | 2,138,080k (± 0.01%) | +4,253k (+ 0.20%) | 2,137,887k | 2,138,228k | p=0.005 n=6 |
| Parse Time | 7.22s (± 0.25%) | 7.24s (± 0.39%) | ~ | 7.21s | 7.29s | p=0.256 n=6 |
| Bind Time | 2.52s (± 0.39%) | 2.53s (± 0.41%) | ~ | 2.52s | 2.55s | p=0.103 n=6 |
| Check Time | 74.09s (± 0.26%) | 74.34s (± 0.45%) | ~ | 73.88s | 74.77s | p=0.173 n=6 |
| Emit Time | 0.16s (± 3.29%) | 0.16s (± 4.75%) | ~ | 0.15s | 0.17s | p=0.784 n=6 |
| Total Time | 83.99s (± 0.21%) | 84.27s (± 0.38%) | ~ | 83.82s | 84.68s | p=0.128 n=6 |
| self-build-src - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 1,226,713 | 1,227,156 | +443 (+ 0.04%) | ~ | ~ | p=0.001 n=6 |
| Types | 266,991 | 267,114 | +123 (+ 0.05%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 2,357,851k (± 0.02%) | 2,360,494k (± 0.02%) | +2,643k (+ 0.11%) | 2,359,892k | 2,361,297k | p=0.005 n=6 |
| Parse Time | 5.19s (± 1.21%) | 5.22s (± 0.66%) | ~ | 5.19s | 5.28s | p=0.521 n=6 |
| Bind Time | 1.80s (± 1.82%) | 1.81s (± 0.57%) | ~ | 1.80s | 1.82s | p=0.806 n=6 |
| Check Time | 35.31s (± 0.34%) | 35.38s (± 0.17%) | ~ | 35.30s | 35.45s | p=0.297 n=6 |
| Emit Time | 2.99s (± 1.21%) | 3.00s (± 1.38%) | ~ | 2.96s | 3.06s | p=0.574 n=6 |
| Total Time | 45.29s (± 0.40%) | 45.41s (± 0.17%) | ~ | 45.32s | 45.54s | p=0.230 n=6 |
| self-build-src-public-api - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 1,226,713 | 1,227,156 | +443 (+ 0.04%) | ~ | ~ | p=0.001 n=6 |
| Types | 266,991 | 267,114 | +123 (+ 0.05%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 2,910,623k (±12.87%) | 3,037,919k (± 9.77%) | 🔻+127,296k (+ 4.37%) | 2,431,304k | 3,160,174k | p=0.031 n=6 |
| Parse Time | 6.94s (± 1.85%) | 7.00s (± 1.66%) | ~ | 6.78s | 7.12s | p=0.471 n=6 |
| Bind Time | 2.14s (± 0.71%) | 2.16s (± 1.07%) | ~ | 2.14s | 2.20s | p=0.126 n=6 |
| Check Time | 42.89s (± 0.52%) | 43.02s (± 0.72%) | ~ | 42.42s | 43.26s | p=0.230 n=6 |
| Emit Time | 3.57s (± 1.32%) | 3.53s (± 2.18%) | ~ | 3.44s | 3.65s | p=0.336 n=6 |
| Total Time | 55.54s (± 0.64%) | 55.70s (± 0.71%) | ~ | 54.98s | 56.18s | p=0.378 n=6 |
| self-compiler - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 262,674 | 263,095 | +421 (+ 0.16%) | ~ | ~ | p=0.001 n=6 |
| Types | 106,849 | 106,972 | +123 (+ 0.12%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 440,508k (± 0.01%) | 441,629k (± 0.02%) | +1,120k (+ 0.25%) | 441,562k | 441,739k | p=0.005 n=6 |
| Parse Time | 3.55s (± 0.66%) | 3.56s (± 0.54%) | ~ | 3.54s | 3.59s | p=0.465 n=6 |
| Bind Time | 1.30s (± 0.64%) | 1.30s (± 0.42%) | ~ | 1.30s | 1.31s | p=0.855 n=6 |
| Check Time | 18.93s (± 0.57%) | 19.00s (± 0.44%) | ~ | 18.90s | 19.10s | p=0.520 n=6 |
| Emit Time | 1.52s (± 1.15%) | 1.51s (± 1.08%) | ~ | 1.49s | 1.54s | p=0.934 n=6 |
| Total Time | 25.31s (± 0.53%) | 25.38s (± 0.32%) | ~ | 25.29s | 25.47s | p=0.688 n=6 |
| ts-pre-modules - node (v18.15.0, x64) | ||||||
| Errors | 71 | 71 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 225,981 | 225,981 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 94,356 | 94,356 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 371,202k (± 0.02%) | 371,814k (± 0.04%) | +612k (+ 0.16%) | 371,656k | 372,006k | p=0.005 n=6 |
| Parse Time | 2.89s (± 0.63%) | 2.89s (± 0.87%) | ~ | 2.86s | 2.93s | p=0.807 n=6 |
| Bind Time | 1.61s (± 2.02%) | 1.61s (± 1.27%) | ~ | 1.58s | 1.64s | p=0.871 n=6 |
| Check Time | 16.49s (± 0.37%) | 16.50s (± 0.47%) | ~ | 16.40s | 16.60s | p=0.936 n=6 |
| Emit Time | 0.00s | 0.00s | ~ | ~ | ~ | p=1.000 n=6 |
| Total Time | 20.99s (± 0.31%) | 20.99s (± 0.32%) | ~ | 20.89s | 21.09s | p=1.000 n=6 |
| vscode - node (v18.15.0, x64) | ||||||
| Errors | 8 | 8 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 3,320,535 | 3,320,535 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 1,125,763 | 1,125,763 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 3,382,323k (± 0.00%) | 3,387,326k (± 0.01%) | +5,003k (+ 0.15%) | 3,386,997k | 3,387,570k | p=0.005 n=6 |
| Parse Time | 14.78s (± 3.65%) | 14.66s (± 0.63%) | ~ | 14.56s | 14.80s | p=0.229 n=6 |
| Bind Time | 4.65s (± 0.42%) | 4.71s (± 2.25%) | ~ | 4.65s | 4.93s | p=0.075 n=6 |
| Check Time | 91.25s (± 1.44%) | 92.39s (± 3.01%) | ~ | 88.97s | 96.95s | p=0.471 n=6 |
| Emit Time | 29.29s (± 0.55%) | 29.91s (± 2.63%) | ~ | 29.10s | 30.93s | p=0.128 n=6 |
| Total Time | 139.96s (± 0.96%) | 141.67s (± 1.59%) | ~ | 138.32s | 145.29s | p=0.173 n=6 |
| webpack - node (v18.15.0, x64) | ||||||
| Errors | 2 | 2 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 308,237 | 308,237 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 134,948 | 134,948 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 463,416k (± 0.03%) | 463,566k (± 0.02%) | ~ | 463,395k | 463,653k | p=0.078 n=6 |
| Parse Time | 4.14s (± 0.47%) | 4.11s (± 0.78%) | ~ | 4.06s | 4.14s | p=0.088 n=6 |
| Bind Time | 1.80s (± 1.24%) | 1.80s (± 1.35%) | ~ | 1.75s | 1.82s | p=0.622 n=6 |
| Check Time | 20.40s (± 0.16%) | 20.46s (± 0.48%) | ~ | 20.29s | 20.57s | p=0.127 n=6 |
| Emit Time | 0.00s (±244.70%) | 0.00s | ~ | ~ | ~ | p=0.405 n=6 |
| Total Time | 26.34s (± 0.21%) | 26.36s (± 0.27%) | ~ | 26.24s | 26.45s | p=0.226 n=6 |
| xstate-main - node (v18.15.0, x64) | ||||||
| Errors | 5 | 5 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 566,532 | 566,532 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 189,740 | 189,740 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 497,449k (± 0.01%) | 497,946k (± 0.02%) | +498k (+ 0.10%) | 497,832k | 498,093k | p=0.005 n=6 |
| Parse Time | 4.19s (± 0.49%) | 4.17s (± 0.70%) | ~ | 4.12s | 4.20s | p=0.191 n=6 |
| Bind Time | 1.50s (± 1.19%) | 1.50s (± 1.03%) | ~ | 1.48s | 1.52s | p=1.000 n=6 |
| Check Time | 24.73s (± 0.25%) | 24.85s (± 0.27%) | +0.11s (+ 0.46%) | 24.74s | 24.93s | p=0.020 n=6 |
| Emit Time | 0.00s | 0.00s | ~ | ~ | ~ | p=1.000 n=6 |
| Total Time | 30.43s (± 0.29%) | 30.52s (± 0.24%) | ~ | 30.41s | 30.62s | p=0.077 n=6 |
- node (v18.15.0, x64)
- Compiler-Unions - node (v18.15.0, x64)
- angular-1 - node (v18.15.0, x64)
- mui-docs - node (v18.15.0, x64)
- self-build-src - node (v18.15.0, x64)
- self-build-src-public-api - node (v18.15.0, x64)
- self-compiler - node (v18.15.0, x64)
- ts-pre-modules - node (v18.15.0, x64)
- vscode - node (v18.15.0, x64)
- webpack - node (v18.15.0, x64)
- xstate-main - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
@gabritto Here are the results of running the top 400 repos with tsc comparing main and refs/pull/61359/merge:
Everything looks good!
@typescript-bot perf test this faster
Starting jobs; this comment will be updated as builds start and complete.
| Command | Status | Results |
|---|---|---|
perf test this faster |
✅ Started | 👀 Results |
@gabritto The results of the perf run you requested are in!
Here they are:
tsc
Comparison Report - baseline..pr| Metric | baseline | pr | Delta | Best | Worst | p-value |
|---|---|---|---|---|---|---|
| Compiler-Unions - node (v18.15.0, x64) | ||||||
| Errors | 34 | 34 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 62,390 | 62,390 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 50,395 | 50,395 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 194,255k (± 0.92%) | 193,140k (± 0.01%) | ~ | 193,110k | 193,184k | p=0.378 n=6 |
| Parse Time | 1.31s (± 0.68%) | 1.32s (± 0.42%) | ~ | 1.31s | 1.32s | p=0.341 n=6 |
| Bind Time | 0.73s | 0.73s | ~ | ~ | ~ | p=1.000 n=6 |
| Check Time | 9.74s (± 0.28%) | 9.74s (± 0.47%) | ~ | 9.69s | 9.80s | p=1.000 n=6 |
| Emit Time | 2.73s (± 0.55%) | 2.73s (± 0.51%) | ~ | 2.71s | 2.74s | p=0.461 n=6 |
| Total Time | 14.51s (± 0.23%) | 14.51s (± 0.32%) | ~ | 14.46s | 14.57s | p=0.872 n=6 |
| angular-1 - node (v18.15.0, x64) | ||||||
| Errors | 56 | 56 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 948,670 | 948,670 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 410,947 | 410,947 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 1,224,347k (± 0.01%) | 1,225,556k (± 0.00%) | +1,209k (+ 0.10%) | 1,225,534k | 1,225,574k | p=0.005 n=6 |
| Parse Time | 6.62s (± 0.92%) | 6.67s (± 0.41%) | ~ | 6.63s | 6.70s | p=0.332 n=6 |
| Bind Time | 1.88s (± 0.43%) | 1.87s (± 0.28%) | -0.01s (- 0.53%) | 1.87s | 1.88s | p=0.050 n=6 |
| Check Time | 31.88s (± 0.45%) | 31.98s (± 0.62%) | ~ | 31.73s | 32.27s | p=0.575 n=6 |
| Emit Time | 15.31s (± 0.48%) | 15.19s (± 0.68%) | ~ | 15.08s | 15.35s | p=0.066 n=6 |
| Total Time | 55.69s (± 0.37%) | 55.71s (± 0.53%) | ~ | 55.39s | 56.07s | p=1.000 n=6 |
| mui-docs - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 2,338,004 | 2,338,004 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 832,025 | 832,025 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 2,105,904k (± 0.00%) | 2,109,988k (± 0.00%) | +4,084k (+ 0.19%) | 2,109,951k | 2,110,056k | p=0.005 n=6 |
| Parse Time | 7.21s (± 0.08%) | 7.21s (± 0.30%) | ~ | 7.20s | 7.25s | p=0.363 n=6 |
| Bind Time | 2.50s (± 0.30%) | 2.51s (± 0.48%) | ~ | 2.50s | 2.53s | p=0.652 n=6 |
| Check Time | 73.38s (± 0.38%) | 73.76s (± 0.53%) | ~ | 73.26s | 74.22s | p=0.173 n=6 |
| Emit Time | 0.16s | 0.16s (± 3.95%) | ~ | 0.15s | 0.17s | p=1.000 n=6 |
| Total Time | 83.26s (± 0.34%) | 83.64s (± 0.47%) | ~ | 83.13s | 84.11s | p=0.173 n=6 |
| self-build-src - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 1,226,713 | 1,227,156 | +443 (+ 0.04%) | ~ | ~ | p=0.001 n=6 |
| Types | 266,991 | 267,114 | +123 (+ 0.05%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 2,357,352k (± 0.03%) | 2,360,552k (± 0.02%) | +3,200k (+ 0.14%) | 2,359,990k | 2,361,021k | p=0.005 n=6 |
| Parse Time | 5.20s (± 0.47%) | 5.19s (± 1.09%) | ~ | 5.12s | 5.29s | p=0.688 n=6 |
| Bind Time | 1.80s (± 0.93%) | 1.80s (± 0.96%) | ~ | 1.78s | 1.83s | p=0.932 n=6 |
| Check Time | 35.32s (± 0.23%) | 35.35s (± 0.28%) | ~ | 35.20s | 35.44s | p=0.378 n=6 |
| Emit Time | 3.02s (± 0.99%) | 3.00s (± 0.81%) | ~ | 2.95s | 3.01s | p=0.166 n=6 |
| Total Time | 45.35s (± 0.21%) | 45.34s (± 0.26%) | ~ | 45.22s | 45.53s | p=0.873 n=6 |
| self-build-src-public-api - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 1,226,713 | 1,227,156 | +443 (+ 0.04%) | ~ | ~ | p=0.001 n=6 |
| Types | 266,991 | 267,114 | +123 (+ 0.05%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 2,911,756k (±12.87%) | 2,916,546k (±12.87%) | ~ | 2,431,200k | 3,159,843k | p=0.128 n=6 |
| Parse Time | 6.91s (± 1.62%) | 6.92s (± 1.86%) | ~ | 6.78s | 7.07s | p=1.000 n=6 |
| Bind Time | 2.12s (± 2.05%) | 2.17s (± 1.28%) | ~ | 2.15s | 2.22s | p=0.170 n=6 |
| Check Time | 42.78s (± 0.51%) | 42.89s (± 0.68%) | ~ | 42.53s | 43.26s | p=0.471 n=6 |
| Emit Time | 3.46s (± 2.23%) | 3.42s (± 2.45%) | ~ | 3.35s | 3.58s | p=0.471 n=6 |
| Total Time | 55.29s (± 0.49%) | 55.39s (± 0.73%) | ~ | 54.90s | 55.84s | p=0.810 n=6 |
| self-compiler - node (v18.15.0, x64) | ||||||
| Errors | 0 | 0 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 262,674 | 263,095 | +421 (+ 0.16%) | ~ | ~ | p=0.001 n=6 |
| Types | 106,849 | 106,972 | +123 (+ 0.12%) | ~ | ~ | p=0.001 n=6 |
| Memory used | 440,467k (± 0.01%) | 441,611k (± 0.02%) | +1,145k (+ 0.26%) | 441,501k | 441,749k | p=0.005 n=6 |
| Parse Time | 3.53s (± 1.72%) | 3.57s (± 0.89%) | ~ | 3.54s | 3.61s | p=0.169 n=6 |
| Bind Time | 1.32s (± 0.57%) | 1.32s (± 0.88%) | ~ | 1.30s | 1.33s | p=0.396 n=6 |
| Check Time | 18.98s (± 0.22%) | 19.02s (± 0.47%) | ~ | 18.93s | 19.13s | p=0.809 n=6 |
| Emit Time | 1.53s (± 0.99%) | 1.52s (± 1.29%) | ~ | 1.50s | 1.55s | p=0.935 n=6 |
| Total Time | 25.36s (± 0.35%) | 25.43s (± 0.36%) | ~ | 25.31s | 25.57s | p=0.229 n=6 |
| ts-pre-modules - node (v18.15.0, x64) | ||||||
| Errors | 71 | 71 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 225,981 | 225,981 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 94,356 | 94,356 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 371,187k (± 0.02%) | 371,720k (± 0.03%) | +532k (+ 0.14%) | 371,589k | 371,828k | p=0.005 n=6 |
| Parse Time | 2.89s (± 0.55%) | 2.88s (± 1.01%) | ~ | 2.83s | 2.90s | p=0.684 n=6 |
| Bind Time | 1.59s (± 1.30%) | 1.58s (± 1.10%) | ~ | 1.57s | 1.61s | p=0.416 n=6 |
| Check Time | 16.52s (± 0.35%) | 16.47s (± 0.28%) | ~ | 16.41s | 16.52s | p=0.199 n=6 |
| Emit Time | 0.00s | 0.00s | ~ | ~ | ~ | p=1.000 n=6 |
| Total Time | 21.00s (± 0.27%) | 20.93s (± 0.22%) | ~ | 20.88s | 21.00s | p=0.064 n=6 |
| vscode - node (v18.15.0, x64) | ||||||
| Errors | 8 | 8 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 3,323,316 | 3,323,316 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 1,126,439 | 1,126,439 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 3,383,716k (± 0.01%) | 3,389,145k (± 0.01%) | +5,430k (+ 0.16%) | 3,388,828k | 3,389,364k | p=0.005 n=6 |
| Parse Time | 14.60s (± 0.59%) | 14.64s (± 0.49%) | ~ | 14.55s | 14.75s | p=0.376 n=6 |
| Bind Time | 4.66s (± 0.55%) | 4.65s (± 0.78%) | ~ | 4.61s | 4.70s | p=0.630 n=6 |
| Check Time | 91.25s (± 1.89%) | 90.75s (± 1.77%) | ~ | 89.52s | 93.90s | p=0.470 n=6 |
| Emit Time | 29.84s (± 2.63%) | 28.86s (± 6.33%) | ~ | 25.31s | 30.62s | p=0.199 n=6 |
| Total Time | 140.36s (± 1.79%) | 138.91s (± 0.57%) | ~ | 138.09s | 139.93s | p=0.298 n=6 |
| webpack - node (v18.15.0, x64) | ||||||
| Errors | 2 | 2 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 308,237 | 308,237 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 134,948 | 134,948 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 463,361k (± 0.03%) | 463,558k (± 0.02%) | +198k (+ 0.04%) | 463,429k | 463,661k | p=0.031 n=6 |
| Parse Time | 4.11s (± 0.50%) | 4.10s (± 0.82%) | ~ | 4.06s | 4.16s | p=0.572 n=6 |
| Bind Time | 1.80s (± 0.55%) | 1.80s (± 1.15%) | ~ | 1.76s | 1.82s | p=0.869 n=6 |
| Check Time | 20.46s (± 0.38%) | 20.43s (± 0.26%) | ~ | 20.37s | 20.52s | p=0.747 n=6 |
| Emit Time | 0.00s | 0.00s (±244.70%) | ~ | 0.00s | 0.01s | p=0.405 n=6 |
| Total Time | 26.36s (± 0.33%) | 26.33s (± 0.14%) | ~ | 26.28s | 26.38s | p=0.687 n=6 |
| xstate-main - node (v18.15.0, x64) | ||||||
| Errors | 5 | 5 | ~ | ~ | ~ | p=1.000 n=6 |
| Symbols | 566,532 | 566,532 | ~ | ~ | ~ | p=1.000 n=6 |
| Types | 189,740 | 189,740 | ~ | ~ | ~ | p=1.000 n=6 |
| Memory used | 497,380k (± 0.04%) | 497,910k (± 0.02%) | +530k (+ 0.11%) | 497,738k | 498,004k | p=0.005 n=6 |
| Parse Time | 4.18s (± 0.49%) | 4.17s (± 0.91%) | ~ | 4.12s | 4.20s | p=0.685 n=6 |
| Bind Time | 1.51s (± 0.68%) | 1.50s (± 0.91%) | ~ | 1.48s | 1.52s | p=0.190 n=6 |
| Check Time | 24.95s (± 1.24%) | 24.77s (± 0.48%) | ~ | 24.58s | 24.88s | p=0.261 n=6 |
| Emit Time | 0.00s (±244.70%) | 0.00s | ~ | ~ | ~ | p=0.405 n=6 |
| Total Time | 30.64s (± 0.96%) | 30.43s (± 0.45%) | ~ | 30.25s | 30.60s | p=0.128 n=6 |
- node (v18.15.0, x64)
- Compiler-Unions - node (v18.15.0, x64)
- angular-1 - node (v18.15.0, x64)
- mui-docs - node (v18.15.0, x64)
- self-build-src - node (v18.15.0, x64)
- self-build-src-public-api - node (v18.15.0, x64)
- self-compiler - node (v18.15.0, x64)
- ts-pre-modules - node (v18.15.0, x64)
- vscode - node (v18.15.0, x64)
- webpack - node (v18.15.0, x64)
- xstate-main - node (v18.15.0, x64)
| Benchmark | Name | Iterations |
|---|---|---|
| Current | pr | 6 |
| Baseline | baseline | 6 |
Developer Information:
Note to self:
- Add tests with
typeof paramas a way of accessing the narrowable type parameter - Support parameter properties
hi! Not sure where it's the right place to ask this, but are you planning on having this feature re-added in the foreseeable future? Or did you decide to de-prioritize it because of the go port? :)
There’s some discussion on this in https://github.com/microsoft/TypeScript/issues/61648#issuecomment-2849614732:
We want to be more conservative about larger features that are more involved while so much of our attention is currently on the port.
we generally won't plan on new features, but it depends on priority, finding improvements that need to be backported during the port, etc. We just don't want to split our focus too much.