Skip to content

Conversation

@ahejlsberg
Copy link
Member

@ahejlsbergahejlsberg commented Jul 26, 2024

This PR builds on #59415 to implement the following in aggregate:

  • In an indexed access expression obj[key], when obj and key both have generic types we no longer require the constraint of obj to be a non-nullable type. The rationale for this change is that when key is a valid property name for obj, it must be because obj is of a non-nullable type, as discussed here.
  • We now consider unconstrained generic types and generic types constrained to unknown to possibly be null or undefined in --strictNullChecks mode. Previously, we would only consider generic types with constraints including null or undefined to possibly be nullable.

Fixes#50603.

@ahejlsberg
Copy link
MemberAuthor

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jul 26, 2024

Starting jobs; this comment will be updated as builds start and complete.

CommandStatusResults
test top400✅ Started👀 Results
user test this✅ Started✅ Results
run dt✅ Started✅ Results
perf test this faster✅ Started👀 Results

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the user tests with tsc comparing main and refs/pull/59437/merge:

Everything looks good!

@typescript-bot
Copy link
Collaborator

Hey @ahejlsberg, the results of running the DT tests are ready.

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

@ahejlsberg
The results of the perf run you requested are in!

Here they are:

tsc

Comparison Report - baseline..pr
MetricbaselineprDeltaBestWorstp-value
Compiler-Unions - node (v18.15.0, x64)
Errors3030~~~p=1.000 n=6
Symbols62,15362,153~~~p=1.000 n=6
Types50,24250,242~~~p=1.000 n=6
Memory used193,065k (± 0.72%)194,729k (± 0.96%)~192,305k196,060kp=0.378 n=6
Parse Time1.30s (± 1.57%)1.31s (± 0.89%)~1.29s1.32sp=0.391 n=6
Bind Time0.71s0.71s~~~p=1.000 n=6
Check Time9.59s (± 0.41%)9.53s (± 0.32%)-0.06s (- 0.63%)9.47s9.56sp=0.024 n=6
Emit Time2.74s (± 0.78%)2.72s (± 1.38%)~2.65s2.76sp=0.293 n=6
Total Time14.33s (± 0.23%)14.26s (± 0.48%)-0.07s (- 0.52%)14.13s14.32sp=0.016 n=6
angular-1 - node (v18.15.0, x64)
Errors717🔻+10 (+142.86%)~~p=0.001 n=6
Symbols945,532945,532~~~p=1.000 n=6
Types409,507409,512+5 (+ 0.00%)~~p=0.001 n=6
Memory used1,221,152k (± 0.00%)1,221,178k (± 0.00%)~1,221,099k1,221,213kp=0.630 n=6
Parse Time6.68s (± 0.83%)6.68s (± 0.57%)~6.64s6.75sp=1.000 n=6
Bind Time1.90s (± 0.54%)1.90s (± 0.58%)~1.89s1.92sp=0.558 n=6
Check Time31.26s (± 0.27%)31.25s (± 0.57%)~31.08s31.51sp=0.377 n=6
Emit Time15.18s (± 0.40%)15.19s (± 0.33%)~15.14s15.27sp=0.809 n=6
Total Time55.02s (± 0.19%)55.02s (± 0.37%)~54.87s55.33sp=0.687 n=6
mui-docs - node (v18.15.0, x64)
Errors016🔻+16 (+ ∞%)~~p=0.001 n=6
Symbols2,437,2532,437,253~~~p=1.000 n=6
Types1,004,0971,004,141+44 (+ 0.00%)~~p=0.001 n=6
Memory used2,426,339k (± 0.00%)2,426,265k (± 0.00%)~2,426,226k2,426,333kp=0.066 n=6
Parse Time8.43s (± 0.31%)8.44s (± 0.21%)~8.42s8.47sp=0.686 n=6
Bind Time2.08s (± 0.56%)2.08s (± 0.30%)~2.07s2.09sp=1.000 n=6
Check Time75.18s (± 0.66%)74.77s (± 0.39%)-0.40s (- 0.54%)74.23s75.00sp=0.045 n=6
Emit Time0.28s (± 1.47%)0.28s (± 1.47%)~0.27s0.28sp=1.000 n=6
Total Time85.96s (± 0.59%)85.57s (± 0.32%)~85.06s85.77sp=0.066 n=6
self-build-src - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,227,7351,227,781+46 (+ 0.00%)~~p=0.001 n=6
Types265,136265,143+7 (+ 0.00%)~~p=0.001 n=6
Memory used2,346,556k (± 0.01%)2,346,515k (± 0.03%)~2,345,869k2,347,878kp=0.378 n=6
Parse Time5.03s (± 0.57%)5.01s (± 1.07%)~4.94s5.08sp=0.471 n=6
Bind Time1.92s (± 0.43%)1.92s (± 0.39%)~1.91s1.93sp=0.729 n=6
Check Time34.74s (± 0.57%)34.78s (± 0.22%)~34.69s34.89sp=0.936 n=6
Emit Time3.33s (± 0.94%)3.30s (± 1.61%)~3.21s3.35sp=0.229 n=6
Total Time45.03s (± 0.46%)45.03s (± 0.27%)~44.90s45.20sp=0.936 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols1,227,7351,227,781+46 (+ 0.00%)~~p=0.001 n=6
Types265,136265,143+7 (+ 0.00%)~~p=0.001 n=6
Memory used2,420,283k (± 0.03%)2,420,571k (± 0.03%)~2,419,926k2,421,919kp=1.000 n=6
Parse Time6.19s (± 0.70%)6.19s (± 0.69%)~6.14s6.25sp=1.000 n=6
Bind Time2.02s (± 1.15%)2.03s (± 0.86%)~2.01s2.06sp=0.373 n=6
Check Time41.17s (± 0.26%)41.05s (± 0.19%)~40.94s41.17sp=0.093 n=6
Emit Time4.12s (± 4.15%)4.00s (± 1.06%)~3.95s4.07sp=0.107 n=6
Total Time53.51s (± 0.35%)53.30s (± 0.27%)~53.06s53.47sp=0.066 n=6
self-compiler - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols255,950255,952+2 (+ 0.00%)~~p=0.001 n=6
Types104,957104,964+7 (+ 0.01%)~~p=0.001 n=6
Memory used427,965k (± 0.04%)427,955k (± 0.04%)~427,739k428,298kp=0.936 n=6
Parse Time3.35s (± 0.70%)3.36s (± 0.69%)~3.33s3.39sp=0.624 n=6
Bind Time1.32s (± 0.88%)1.31s (± 1.42%)~1.29s1.33sp=0.445 n=6
Check Time17.98s (± 0.45%)18.00s (± 0.39%)~17.90s18.06sp=0.809 n=6
Emit Time1.65s (± 1.04%)1.64s (± 1.37%)~1.62s1.67sp=0.682 n=6
Total Time24.31s (± 0.27%)24.32s (± 0.33%)~24.21s24.39sp=0.810 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors3535~~~p=1.000 n=6
Symbols224,931224,931~~~p=1.000 n=6
Types94,14694,146~~~p=1.000 n=6
Memory used370,148k (± 0.04%)370,101k (± 0.04%)~369,914k370,319kp=0.630 n=6
Parse Time2.76s (± 0.78%)2.76s (± 0.42%)~2.74s2.77sp=0.625 n=6
Bind Time1.58s (± 1.09%)1.58s (± 1.30%)~1.55s1.61sp=0.514 n=6
Check Time15.67s (± 0.23%)15.71s (± 0.21%)~15.65s15.75sp=0.053 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time20.01s (± 0.13%)20.05s (± 0.07%)+0.04s (+ 0.19%)20.03s20.07sp=0.024 n=6
vscode - node (v18.15.0, x64)
Errors1111~~~p=1.000 n=6
Symbols2,986,8392,986,839~~~p=1.000 n=6
Types1,027,4681,027,468~~~p=1.000 n=6
Memory used3,110,626k (± 0.00%)3,110,688k (± 0.00%)~3,110,618k3,110,747kp=0.128 n=6
Parse Time13.87s (± 0.52%)13.84s (± 0.40%)~13.76s13.93sp=0.687 n=6
Bind Time4.35s (± 2.77%)4.32s (± 2.02%)~4.28s4.50sp=0.624 n=6
Check Time79.38s (± 0.42%)79.18s (± 0.30%)~78.91s79.54sp=0.298 n=6
Emit Time20.52s (± 0.37%)20.50s (± 0.76%)~20.23s20.63sp=1.000 n=6
Total Time118.12s (± 0.34%)117.84s (± 0.29%)~117.37s118.35sp=0.298 n=6
webpack - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols267,567267,567~~~p=1.000 n=6
Types109,077109,077~~~p=1.000 n=6
Memory used412,438k (± 0.01%)412,463k (± 0.02%)~412,378k412,539kp=0.689 n=6
Parse Time3.80s (± 0.86%)3.82s (± 0.59%)~3.78s3.85sp=0.744 n=6
Bind Time1.70s (± 0.64%)1.71s (± 0.86%)~1.68s1.72sp=0.131 n=6
Check Time16.85s (± 0.38%)16.82s (± 0.43%)~16.74s16.94sp=0.471 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time22.36s (± 0.31%)22.34s (± 0.43%)~22.26s22.52sp=0.574 n=6
xstate-main - node (v18.15.0, x64)
Errors00~~~p=1.000 n=6
Symbols511,807511,807~~~p=1.000 n=6
Types162,090162,090~~~p=1.000 n=6
Memory used449,073k (± 0.08%)449,313k (± 0.03%)~449,121k449,516kp=0.298 n=6
Parse Time3.16s (± 0.51%)3.16s (± 0.62%)~3.13s3.18sp=0.618 n=6
Bind Time1.16s (± 1.01%)1.16s (± 0.35%)~1.15s1.16sp=0.787 n=6
Check Time17.16s (± 0.33%)17.18s (± 0.50%)~17.07s17.33sp=0.748 n=6
Emit Time0.00s0.00s~~~p=1.000 n=6
Total Time21.48s (± 0.29%)21.50s (± 0.43%)~21.35s21.63sp=0.936 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • 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)
BenchmarkNameIterations
Currentpr6
Baselinebaseline6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@ahejlsberg Here are the results of running the top 400 repos with tsc comparing main and refs/pull/59437/merge:

Something interesting changed - please have a look.

Details

ag-grid/ag-grid

31 of 110 projects failed to build with the old tsc and were ignored

enterprise-modules/viewport-row-model/tsconfig.watch.json

enterprise-modules/viewport-row-model/tsconfig.types.watch.json

enterprise-modules/status-bar/tsconfig.watch.json

enterprise-modules/status-bar/tsconfig.types.watch.json

enterprise-modules/sparklines/tsconfig.watch.json

enterprise-modules/sparklines/tsconfig.types.watch.json

enterprise-modules/side-bar/tsconfig.watch.json

enterprise-modules/side-bar/tsconfig.types.watch.json

enterprise-modules/set-filter/tsconfig.watch.json

enterprise-modules/set-filter/tsconfig.types.watch.json

enterprise-modules/server-side-row-model/tsconfig.watch.json

enterprise-modules/server-side-row-model/tsconfig.types.watch.json

enterprise-modules/row-grouping/tsconfig.watch.json

enterprise-modules/row-grouping/tsconfig.types.watch.json

enterprise-modules/rich-select/tsconfig.watch.json

enterprise-modules/rich-select/tsconfig.types.watch.json

enterprise-modules/range-selection/tsconfig.watch.json

enterprise-modules/range-selection/tsconfig.types.watch.json

enterprise-modules/multi-filter/tsconfig.watch.json

enterprise-modules/multi-filter/tsconfig.types.watch.json

enterprise-modules/master-detail/tsconfig.watch.json

enterprise-modules/master-detail/tsconfig.types.watch.json

enterprise-modules/filter-tool-panel/tsconfig.watch.json

enterprise-modules/filter-tool-panel/tsconfig.types.watch.json

enterprise-modules/core/tsconfig.watch.json

enterprise-modules/core/tsconfig.types.watch.json

enterprise-modules/advanced-filter/tsconfig.watch.json

enterprise-modules/advanced-filter/tsconfig.types.watch.json

community-modules/vue3/tsconfig.watch.json

community-modules/vue3/tsconfig.types.watch.json

community-modules/infinite-row-model/tsconfig.watch.json

community-modules/infinite-row-model/tsconfig.types.watch.json

community-modules/csv-export/tsconfig.watch.json

community-modules/csv-export/tsconfig.types.watch.json

community-modules/core/tsconfig.watch.json

community-modules/core/tsconfig.types.watch.json

community-modules/client-side-row-model/tsconfig.watch.json

community-modules/client-side-row-model/tsconfig.types.watch.json

compiler-explorer/compiler-explorer

4 of 6 projects failed to build with the old tsc and were ignored

static/tsconfig.json

desktop/desktop

1 of 4 projects failed to build with the old tsc and were ignored

tsconfig.json

sequelize/sequelize

13 of 16 projects failed to build with the old tsc and were ignored

packages/utils/tsconfig.json

@ahejlsberg
Copy link
MemberAuthor

ahejlsberg commented Jul 29, 2024

The new errors in the top 400 repos tests are all the same: Functions that compare values of unconstrained generic types. Our existing behavior is to permit such comparisons--we only error when the types have constraints that explicitly include null or undefined (which obviously is inconsistent).

We should decide if we think erroring on generic operands that are possibly null or undefined is the right thing to do since it basically amounts to a breaking change. The semantics of comparisons involving null and undefined are well defined (they act like NaN) and don't cause exceptions, yet it's probably rare for such comparisons to be intended.

@ahejlsberg
Copy link
MemberAuthor

We're going to wait for 5.7 on this one since it is technically a breaking change.

@jakebailey
Copy link
Member

5.7 happened, and we're now at 5.8... should we do this? 😄

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: TeamFor Milestone BugPRs that fix a bug with a specific milestone

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

No error on unconstrained type parameter in > comparison

5 participants

@ahejlsberg@typescript-bot@jakebailey@iisaduan