Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TReturn/TNext to Iterable et al #58243

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

rbuckton
Copy link
Member

@rbuckton rbuckton commented Apr 18, 2024

We avoided making this change in the past as it was very breaky, but at some point we need to address this discrepancy. Having incorrect types here is also causing problems with properly typing the Iterator Helpers proposal.

This also adds a new BuiltinIteratorReturn intrinsic type whose actual type is determined by the state of a new strictBuiltinIteratorReturn compiler option:

  • "strictBuiltinIteratorReturn": false - any (emulates current behavior for IterableIterator)
  • "strictBuiltinIteratorReturn": true - undefined

The strictBuiltinIteratorReturn is a strict option flag, meaning that it is enabled automatically when you set "strict": true in your tsconfig.json.

The new BuiltinIteratorReturn type is passed as the TReturn type argument for built-ins using IterableIterator or AsyncIterableIterator to enable stricter checks against the result of calling next() on the iterator.

Enabling strictBuiltinIteratorReturn results in a more accurate and type-safe return type for the next() methods of iterators produced by built-ins like Array, Set, Map, etc.:

// @strictBuiltinIteratorReturn: false
// NOTE: matches current behavior

const set = new Set(["a"]);
const result = set.keys().next();
//    ^?  result: IteratorResult<string, any>
const value = result.value;
//    ^?  value: any

if (!result.done) {
  const value = result.value;
  //    ^?  value: string
} else {
  const value = result.value;
  //    ^?  value: any
}

vs

// @strictBuiltinIteratorReturn: true

const set = new Set(["a"]);
const result = set.keys().next();
//    ^?  result: IteratorResult<string, undefined>
const value = result.value;
//    ^?  value: string | undefined

if (!result.done) {
  const value = result.value;
  //    ^?  value: string
} else {
  const value = result.value;
  //    ^?  value: undefined
}

Since this is a strict flag, there is a fair amount of existing code that will likely produce new compilation errors as a result of this change:

// @strict: true

function only<T>(set: Set<T>): T {
  if (set.size !== 1) throw new TypeError();
  return set.keys().next().value; // worked previously since result was `any`, but is now an error
}

This now fails as there is no correlation between set.size and the iterator produced by keys(), so the compiler is unaware that this constraint has been validated. If you are certain iterator will always yield at least one value, you can use a non-null assertion operator to strip off the | undefined:

// @strict: true

function only<T>(set: Set<T>): T {
  if (set.size !== 1) throw new TypeError();
  return set.keys().next().value!;
}

A follow-on PR to TypeScript-DOM-lib-generator can be found here: microsoft/TypeScript-DOM-lib-generator#1713

DefinitelyTyped breaks will be addressed by DefinitelyTyped/DefinitelyTyped#69632

Fixes #33353
Fixes #52998
Fixes #43750
Supersedes #56517
Related #58222

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Apr 18, 2024
@rbuckton

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@rbuckton

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@rbuckton

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@rbuckton

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@rbuckton

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@typescript-bot

This comment was marked as outdated.

@rbuckton
Copy link
Member Author

rbuckton commented Apr 19, 2024

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

There were interesting changes:

Changes are too big to display here, please check the log.

You can check the log here.

@jakebailey, @weswigham: Am I missing something? The bot says there were interesting changes but it links to a clean pipeline result.

@typescript-bot
Copy link
Collaborator

@rbuckton
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 30 30 ~ ~ ~ p=1.000 n=6
Symbols 62,154 62,154 ~ ~ ~ p=1.000 n=6
Types 50,273 50,273 ~ ~ ~ p=1.000 n=6
Memory used 194,723k (± 0.93%) 192,857k (± 0.75%) -1,866k (- 0.96%) 192,162k 195,789k p=0.045 n=6
Parse Time 1.54s (± 2.04%) 1.55s (± 1.94%) ~ 1.51s 1.59s p=0.359 n=6
Bind Time 0.87s (± 0.63%) 0.87s (± 1.13%) ~ 0.86s 0.88s p=0.662 n=6
Check Time 11.33s (± 0.33%) 11.34s (± 0.15%) ~ 11.33s 11.37s p=0.506 n=6
Emit Time 3.16s (± 0.40%) 3.15s (± 0.66%) ~ 3.14s 3.19s p=0.366 n=6
Total Time 16.89s (± 0.30%) 16.92s (± 0.12%) ~ 16.90s 16.95s p=0.372 n=6
angular-1 - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 945,322 945,696 +374 (+ 0.04%) ~ ~ p=0.001 n=6
Types 408,110 408,539 +429 (+ 0.11%) ~ ~ p=0.001 n=6
Memory used 1,222,834k (± 0.00%) 1,223,395k (± 0.00%) +560k (+ 0.05%) 1,223,290k 1,223,474k p=0.005 n=6
Parse Time 8.06s (± 0.59%) 8.04s (± 0.31%) ~ 8.01s 8.08s p=0.421 n=6
Bind Time 2.22s (± 0.49%) 2.22s (± 0.61%) ~ 2.21s 2.24s p=0.933 n=6
Check Time 36.33s (± 0.45%) 36.28s (± 0.42%) ~ 36.07s 36.44s p=0.689 n=6
Emit Time 17.42s (± 0.49%) 17.40s (± 0.50%) ~ 17.30s 17.55s p=0.810 n=6
Total Time 64.03s (± 0.33%) 63.94s (± 0.35%) ~ 63.62s 64.25s p=0.575 n=6
mui-docs - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 1,957,115 1,957,301 +186 (+ 0.01%) ~ ~ p=0.001 n=6
Types 676,623 676,785 +162 (+ 0.02%) ~ ~ p=0.001 n=6
Memory used 1,765,486k (± 0.00%) 1,765,825k (± 0.00%) +338k (+ 0.02%) 1,765,731k 1,765,872k p=0.005 n=6
Parse Time 9.74s (± 0.49%) 9.78s (± 0.34%) ~ 9.73s 9.83s p=0.172 n=6
Bind Time 3.33s (± 0.67%) 3.36s (± 0.15%) +0.03s (+ 0.95%) 3.36s 3.37s p=0.004 n=6
Check Time 81.47s (± 0.41%) 81.58s (± 0.41%) ~ 81.21s 82.14s p=0.575 n=6
Emit Time 0.21s (± 4.99%) 0.21s (± 5.21%) ~ 0.20s 0.22s p=0.640 n=6
Total Time 94.75s (± 0.36%) 94.93s (± 0.37%) ~ 94.56s 95.53s p=0.378 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,217,450 1,219,225 +1,775 (+ 0.15%) ~ ~ p=0.001 n=6
Types 259,040 261,332 +2,292 (+ 0.88%) ~ ~ p=0.001 n=6
Memory used 2,329,249k (± 0.06%) 2,330,731k (± 0.03%) +1,482k (+ 0.06%) 2,330,275k 2,331,997k p=0.031 n=6
Parse Time 7.43s (± 1.16%) 7.49s (± 0.54%) ~ 7.43s 7.54s p=0.230 n=6
Bind Time 2.76s (± 0.50%) 2.74s (± 0.55%) ~ 2.72s 2.76s p=0.373 n=6
Check Time 48.75s (± 0.29%) 49.19s (± 0.49%) +0.44s (+ 0.91%) 49.00s 49.65s p=0.005 n=6
Emit Time 3.85s (± 3.32%) 3.91s (± 2.06%) ~ 3.76s 3.98s p=0.575 n=6
Total Time 62.78s (± 0.18%) 63.34s (± 0.50%) +0.56s (+ 0.89%) 62.97s 63.92s p=0.005 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 1,217,450 1,219,225 +1,775 (+ 0.15%) ~ ~ p=0.001 n=6
Types 259,040 261,332 +2,292 (+ 0.88%) ~ ~ p=0.001 n=6
Memory used 2,404,031k (± 0.04%) 2,406,246k (± 0.04%) +2,215k (+ 0.09%) 2,405,360k 2,407,638k p=0.005 n=6
Parse Time 7.63s (± 0.84%) 7.73s (± 0.48%) +0.10s (+ 1.27%) 7.68s 7.77s p=0.031 n=6
Bind Time 2.44s (± 1.36%) 2.44s (± 1.31%) ~ 2.40s 2.49s p=0.809 n=6
Check Time 49.19s (± 0.36%) 49.47s (± 0.35%) +0.29s (+ 0.59%) 49.35s 49.78s p=0.045 n=6
Emit Time 3.83s (± 2.12%) 3.88s (± 4.03%) ~ 3.76s 4.17s p=0.575 n=6
Total Time 63.11s (± 0.26%) 63.54s (± 0.39%) +0.43s (+ 0.68%) 63.30s 63.92s p=0.013 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 256,369 256,605 +236 (+ 0.09%) ~ ~ p=0.001 n=6
Types 104,483 104,764 +281 (+ 0.27%) ~ ~ p=0.001 n=6
Memory used 424,975k (± 0.00%) 425,363k (± 0.00%) +388k (+ 0.09%) 425,342k 425,387k p=0.005 n=6
Parse Time 3.36s (± 0.44%) 3.37s (± 0.41%) ~ 3.34s 3.38s p=0.460 n=6
Bind Time 1.31s (± 0.75%) 1.31s (± 0.57%) ~ 1.30s 1.32s p=0.652 n=6
Check Time 17.71s (± 0.26%) 17.81s (± 0.59%) ~ 17.71s 17.95s p=0.107 n=6
Emit Time 1.36s (± 1.11%) 1.37s (± 0.75%) ~ 1.36s 1.39s p=0.054 n=6
Total Time 23.74s (± 0.19%) 23.86s (± 0.47%) ~ 23.73s 23.98s p=0.106 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 35 35 ~ ~ ~ p=1.000 n=6
Symbols 224,826 225,077 +251 (+ 0.11%) ~ ~ p=0.001 n=6
Types 94,115 94,416 +301 (+ 0.32%) ~ ~ p=0.001 n=6
Memory used 370,068k (± 0.02%) 370,209k (± 0.02%) +141k (+ 0.04%) 370,154k 370,310k p=0.020 n=6
Parse Time 3.54s (± 1.10%) 3.50s (± 0.56%) ~ 3.48s 3.53s p=0.147 n=6
Bind Time 1.93s (± 1.07%) 1.94s (± 0.78%) ~ 1.92s 1.96s p=0.458 n=6
Check Time 19.31s (± 0.19%) 19.40s (± 0.34%) +0.10s (+ 0.51%) 19.34s 19.47s p=0.020 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 24.78s (± 0.17%) 24.86s (± 0.22%) +0.08s (+ 0.32%) 24.78s 24.93s p=0.037 n=6
vscode - node (v18.15.0, x64)
Errors 4 4 ~ ~ ~ p=1.000 n=6
Symbols 2,807,132 2,807,353 +221 (+ 0.01%) ~ ~ p=0.001 n=6
Types 952,950 953,161 +211 (+ 0.02%) ~ ~ p=0.001 n=6
Memory used 2,978,824k (± 0.00%) 2,979,600k (± 0.00%) +776k (+ 0.03%) 2,979,434k 2,979,725k p=0.005 n=6
Parse Time 16.97s (± 0.26%) 16.96s (± 0.45%) ~ 16.88s 17.08s p=0.630 n=6
Bind Time 4.99s (± 0.65%) 4.98s (± 0.46%) ~ 4.94s 5.00s p=0.747 n=6
Check Time 88.38s (± 0.52%) 91.32s (± 3.35%) ~ 88.34s 94.40s p=0.066 n=6
Emit Time 28.71s (± 0.53%) 26.56s (± 9.49%) ~ 24.25s 29.25s p=0.173 n=6
Total Time 139.04s (± 0.41%) 139.82s (± 0.50%) ~ 138.88s 140.65s p=0.065 n=6
webpack - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 265,864 266,159 +295 (+ 0.11%) ~ ~ p=0.001 n=6
Types 108,449 108,723 +274 (+ 0.25%) ~ ~ p=0.001 n=6
Memory used 410,533k (± 0.02%) 410,962k (± 0.01%) +429k (+ 0.10%) 410,931k 411,029k p=0.005 n=6
Parse Time 3.19s (± 0.43%) 3.19s (± 0.34%) ~ 3.18s 3.21s p=0.491 n=6
Bind Time 1.40s (± 0.74%) 1.40s (± 1.08%) ~ 1.38s 1.41s p=0.934 n=6
Check Time 14.39s (± 0.40%) 14.36s (± 0.26%) ~ 14.30s 14.39s p=0.172 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 18.98s (± 0.26%) 18.94s (± 0.18%) ~ 18.90s 18.98s p=0.106 n=6
xstate-main - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 524,961 525,025 +64 (+ 0.01%) ~ ~ p=0.001 n=6
Types 179,070 179,148 +78 (+ 0.04%) ~ ~ p=0.001 n=6
Memory used 462,798k (± 0.01%) 463,040k (± 0.02%) +242k (+ 0.05%) 462,957k 463,150k p=0.005 n=6
Parse Time 3.13s (± 0.48%) 3.12s (± 1.12%) ~ 3.10s 3.18s p=0.560 n=6
Bind Time 1.16s (± 0.85%) 1.17s (± 1.17%) ~ 1.15s 1.19s p=0.315 n=6
Check Time 18.23s (± 0.32%) 18.16s (± 0.97%) ~ 17.89s 18.34s p=0.872 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 22.52s (± 0.30%) 22.45s (± 0.60%) ~ 22.26s 22.61s p=0.575 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)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

tsserver

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
Compiler-UnionsTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,297ms (± 0.38%) 2,296ms (± 0.54%) ~ 2,273ms 2,307ms p=0.810 n=6
Req 2 - geterr 5,127ms (± 0.77%) 5,120ms (± 0.46%) ~ 5,100ms 5,156ms p=0.575 n=6
Req 3 - references 283ms (± 0.41%) 289ms (± 2.16%) ~ 283ms 299ms p=0.061 n=6
Req 4 - navto 226ms (± 0.60%) 227ms (± 0.24%) ~ 226ms 227ms p=0.341 n=6
Req 5 - completionInfo count 1,357 1,357 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 82ms (± 9.74%) 77ms (± 0.82%) ~ 76ms 78ms p=0.295 n=6
CompilerTSServer - node (v18.15.0, x64)
Req 1 - updateOpen 2,446ms (± 0.99%) 2,432ms (± 0.79%) ~ 2,417ms 2,469ms p=0.378 n=6
Req 2 - geterr 3,832ms (± 0.28%) 3,841ms (± 0.10%) ~ 3,836ms 3,846ms p=0.065 n=6
Req 3 - references 294ms (± 0.33%) 295ms (± 0.52%) ~ 294ms 298ms p=0.498 n=6
Req 4 - navto 228ms (± 0.24%) 227ms (± 0.28%) ~ 226ms 228ms p=0.201 n=6
Req 5 - completionInfo count 1,519 1,519 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 78ms (± 7.47%) 75ms (± 5.46%) ~ 73ms 83ms p=0.213 n=6
xstate-main-1-tsserver - node (v18.15.0, x64)
Req 1 - updateOpen 5,121ms (± 0.31%) 5,115ms (± 0.37%) ~ 5,088ms 5,138ms p=0.575 n=6
Req 2 - geterr 1,132ms (± 0.72%) 1,119ms (± 1.29%) ~ 1,101ms 1,141ms p=0.078 n=6
Req 3 - references 85ms (± 1.29%) 85ms (± 1.15%) ~ 84ms 87ms p=0.867 n=6
Req 4 - navto 448ms (± 0.18%) 442ms (± 0.97%) ~ 438ms 450ms p=0.061 n=6
Req 5 - completionInfo count 3,413 3,413 ~ ~ ~ p=1.000 n=6
Req 5 - completionInfo 840ms (± 0.85%) 845ms (± 1.16%) ~ 838ms 864ms p=1.000 n=6
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • CompilerTSServer - node (v18.15.0, x64)
  • Compiler-UnionsTSServer - node (v18.15.0, x64)
  • xstate-main-1-tsserver - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

startup

Comparison Report - baseline..pr
Metric baseline pr Delta Best Worst p-value
tsc-startup - node (v18.15.0, x64)
Execution time 157.69ms (± 0.16%) 157.81ms (± 0.20%) +0.12ms (+ 0.07%) 156.55ms 161.88ms p=0.004 n=600
tsserver-startup - node (v18.15.0, x64)
Execution time 240.24ms (± 0.14%) 240.92ms (± 0.83%) +0.68ms (+ 0.28%) 238.74ms 276.27ms p=0.000 n=600
tsserverlibrary-startup - node (v18.15.0, x64)
Execution time 236.18ms (± 0.15%) 236.34ms (± 0.16%) +0.16ms (+ 0.07%) 234.83ms 242.03ms p=0.000 n=600
typescript-startup - node (v18.15.0, x64)
Execution time 236.11ms (± 0.15%) 235.74ms (± 0.17%) -0.37ms (- 0.16%) 234.30ms 241.63ms p=0.000 n=600
System info unknown
Hosts
  • node (v18.15.0, x64)
Scenarios
  • tsc-startup - node (v18.15.0, x64)
  • tsserver-startup - node (v18.15.0, x64)
  • tsserverlibrary-startup - node (v18.15.0, x64)
  • typescript-startup - node (v18.15.0, x64)
Benchmark Name Iterations
Current pr 6
Baseline baseline 6

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

@rbuckton Here are the results of running the top 400 repos comparing main and refs/pull/58243/merge:

Something interesting changed - please have a look.

Details

discordjs/discord.js

38 of 62 projects failed to build with the old tsc and were ignored

packages/collection/tsconfig.json

packages/collection/tsconfig.eslint.json

packages/collection/tsconfig.docs.json

jupyterlab/jupyterlab

44 of 58 projects failed to build with the old tsc and were ignored

packages/ui-components/examples/simple-windowed-list/tsconfig.json

  • error TS2430: Interface 'TextIterator' incorrectly extends interface 'Iterator<string, any, unknown>'.

packages/codeeditor/tsconfig.test.json

examples/filebrowser/src/tsconfig.json

examples/console/src/tsconfig.json

trpc/trpc

28 of 35 projects failed to build with the old tsc and were ignored

packages/server/tsconfig.json

packages/server/tsconfig.benchmark.json

packages/react-query/tsconfig.json

packages/next/tsconfig.watch.json

packages/next/tsconfig.json

packages/client/tsconfig.json

src/lib/es2020.bigint.d.ts Outdated Show resolved Hide resolved
src/lib/es2020.bigint.d.ts Outdated Show resolved Hide resolved
src/lib/es2020.bigint.d.ts Outdated Show resolved Hide resolved
src/lib/es2020.bigint.d.ts Outdated Show resolved Hide resolved
src/lib/es2020.bigint.d.ts Outdated Show resolved Hide resolved
src/lib/es2020.bigint.d.ts Outdated Show resolved Hide resolved
src/lib/es2020.bigint.d.ts Outdated Show resolved Hide resolved
src/lib/es2020.string.d.ts Outdated Show resolved Hide resolved
src/lib/es2020.symbol.wellknown.d.ts Outdated Show resolved Hide resolved
src/lib/es2022.intl.d.ts Outdated Show resolved Hide resolved
@rbuckton
Copy link
Member Author

rbuckton commented May 7, 2024

@typescript-bot: pack this

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 7, 2024

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

Command Status Results
: pack this ✅ Started ✅ Results

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 7, 2024

Hey @rbuckton, 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/161649/artifacts?artifactName=tgz&fileId=C5994DAD6E68EB22CEBC874AC424247EC9A7E65004713CA7344555BE7947DB2202&fileName=/typescript-5.5.0-insiders.20240507.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/pr-build@5.5.0-pr-58243-60".;

@typescript-bot
Copy link
Collaborator

Looks like you're introducing a change to the public API surface area. If this includes breaking changes, please document them on our wiki's API Breaking Changes page.

Also, please make sure @DanielRosenwasser and @RyanCavanaugh are aware of the changes, just as a heads up.

@rbuckton
Copy link
Member Author

@typescript-bot run dt
@typescript-bot test top400
@typescript-bot test tsserver top100
@typescript-bot user test this
@typescript-bot user test tsserver

@typescript-bot
Copy link
Collaborator

typescript-bot commented May 17, 2024

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

Command Status Results
run dt ✅ Started 👀 Results
test top400 ✅ Started 👀 Results
test tsserver top100 ✅ Started
user test this ✅ Started 👀 Results
user test tsserver ✅ Started ✅ Results

@rbuckton rbuckton added Breaking Change Would introduce errors in existing code Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript API Relates to the public API for TypeScript Add a Flag Any problem can be solved by flags, except for the problem of having too many flags labels May 17, 2024
@typescript-bot
Copy link
Collaborator

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

There were interesting changes:

Branch only errors:

Package: regenerator-runtime
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/regenerator-runtime/regenerator-runtime-tests.ts
  135:1  error  TypeScript@local expected type to be:
  Generator<string | awrap<Promise<any>>, void, undefined>
got:
  Generator<string | awrap<Promise<any>>, void, unknown>  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: async-iterable-stream
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/async-iterable-stream/index.d.ts
  4:5  error  TypeScript@local compile error: 
Property 'next' in type 'AsyncIterableStream<T>' is not assignable to the same property in base type 'AsyncIterator<T, any, unknown>'.
  Type '(timeout?: number | undefined) => Promise<IteratorResult<T, any>>' is not assignable to type '(...args: [] | [unknown]) => Promise<IteratorResult<T, any>>'.
    Types of parameters 'timeout' and 'args' are incompatible.
      Type '[] | [unknown]' is not assignable to type '[timeout?: number | undefined]'.
        Type '[unknown]' is not assignable to type '[timeout?: number | undefined]'.
          Type 'unknown' is not assignable to type 'number | undefined'  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: consumable-stream/v1
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/consumable-stream/v1/index.d.ts
  4:5  error  TypeScript@local compile error: 
Property 'next' in type 'ConsumableStream<T>' is not assignable to the same property in base type 'AsyncIterator<T, any, unknown>'.
  Type '(timeout?: number | undefined) => Promise<IteratorResult<T, any>>' is not assignable to type '(...args: [] | [unknown]) => Promise<IteratorResult<T, any>>'.
    Types of parameters 'timeout' and 'args' are incompatible.
      Type '[] | [unknown]' is not assignable to type '[timeout?: number | undefined]'.
        Type '[unknown]' is not assignable to type '[timeout?: number | undefined]'.
          Type 'unknown' is not assignable to type 'number | undefined'  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: consumable-stream
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/consumable-stream/index.d.ts
  4:5  error  TypeScript@local compile error: 
Property 'next' in type 'ConsumableStream<T>' is not assignable to the same property in base type 'AsyncIterator<T, any, unknown>'.
  Type '(timeout?: number | undefined) => Promise<IteratorResult<T, any>>' is not assignable to type '(...args: [] | [unknown]) => Promise<IteratorResult<T, any>>'.
    Types of parameters 'timeout' and 'args' are incompatible.
      Type '[] | [unknown]' is not assignable to type '[timeout?: number | undefined]'.
        Type '[unknown]' is not assignable to type '[timeout?: number | undefined]'.
          Type 'unknown' is not assignable to type 'number | undefined'  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: es-get-iterator
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/es-get-iterator/es-get-iterator-tests.ts
   4:1  error  TypeScript@local expected type to be:
  Iterator<string, any, undefined>
got:
  Iterator<string, any, unknown>                                                                  @definitelytyped/expect
   7:1  error  TypeScript@local expected type to be:
  Iterator<never, any, undefined>
got:
  Iterator<never, any, unknown>                                                                    @definitelytyped/expect
  10:1  error  TypeScript@local expected type to be:
  Iterator<number, any, undefined>
got:
  Iterator<number, any, unknown>                                                                  @definitelytyped/expect
  13:1  error  TypeScript@local expected type to be:
  Iterator<string | number | boolean | undefined, any, undefined>
got:
  Iterator<string | number | boolean | undefined, any, unknown>    @definitelytyped/expect
  16:1  error  TypeScript@local expected type to be:
  Iterator<[symbol, unknown], any, undefined>
got:
  Iterator<[symbol, unknown], any, unknown>                                            @definitelytyped/expect
  19:1  error  TypeScript@local expected type to be:
  Iterator<boolean, any, undefined>
got:
  Iterator<boolean, any, unknown>                                                                @definitelytyped/expect
  36:1  error  TypeScript@local expected type to be:
  Iterator<any, any, undefined>
got:
  Iterator<any, any, unknown>                                                                        @definitelytyped/expect
  40:1  error  TypeScript@local expected type to be:
  Iterator<number, any, undefined> | Iterator<Date, any, undefined>
got:
  Iterator<number, any, unknown> | Iterator<Date, any, unknown>  @definitelytyped/expect
  44:1  error  TypeScript@local expected type to be:
  Iterator<[Error, DataView], any, undefined> | undefined
got:
  Iterator<[Error, DataView], any, unknown> | undefined                    @definitelytyped/expect
  48:1  error  TypeScript@local expected type to be:
  Iterator<unknown, any, undefined> | undefined
got:
  Iterator<unknown, any, unknown> | undefined                                        @definitelytyped/expect

✖ 10 problems (10 errors, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

Package: consumable-stream/v2
Error:

Error: 
/mnt/vss/_work/1/DefinitelyTyped/types/consumable-stream/v2/index.d.ts
  4:5  error  TypeScript@local compile error: 
Property 'next' in type 'ConsumableStream<T>' is not assignable to the same property in base type 'AsyncIterator<T, any, unknown>'.
  Type '(timeout?: number | undefined) => Promise<IteratorResult<T, any>>' is not assignable to type '(...args: [] | [unknown]) => Promise<IteratorResult<T, any>>'.
    Types of parameters 'timeout' and 'args' are incompatible.
      Type '[] | [unknown]' is not assignable to type '[timeout?: number | undefined]'.
        Type '[unknown]' is not assignable to type '[timeout?: number | undefined]'.
          Type 'unknown' is not assignable to type 'number | undefined'  @definitelytyped/expect

✖ 1 problem (1 error, 0 warnings)

    at combineErrorsAndWarnings (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:194:28)
    at runTests (/mnt/vss/_work/1/DefinitelyTyped/node_modules/.pnpm/@definitelytyped+dtslint@0.2.20_typescript@5.5.0-dev.20240517/node_modules/@definitelytyped/dtslint/dist/index.js:186:20)

You can check the log here.

@typescript-bot
Copy link
Collaborator

@rbuckton Here are the results of running the user tests comparing main and refs/pull/58243/merge:

Something interesting changed - please have a look.

Details

effect

tsconfig.json

tsconfig.base.json

  • [NEW] error TS2345: Argument of type '<A extends readonly any[] | Readonly<Record<string, any>>>(a: A) => A' is not assignable to parameter of type '(a: unknown) => readonly any[] | Readonly<Record<string, any>>'.
  • [NEW] error TS2322: Type '<A extends readonly any[] | Readonly<Record<string, any>>>(item: LazyArbitrary<A>) => LazyArbitrary<A>' is not assignable to type '(arbitraries_0: LazyArbitrary<unknown>) => LazyArbitrary<readonly any[] | Readonly<Record<string, any>>>'.
  • [NEW] error TS2322: Type '<A extends readonly any[] | Readonly<Record<string, any>>>(a: A) => A' is not assignable to type '((fromA: unknown) => unknown) | ((fromA: unknown) => unknown)'.
  • [MISSING] error TS2345: Argument of type '<A extends Readonly<Record<string, any>> | ReadonlyArray<any>>(a: A) => A' is not assignable to parameter of type '(a: unknown) => readonly any[] | Readonly<Record<string, any>>'.
  • [MISSING] error TS2322: Type '<A extends Readonly<Record<string, any>> | ReadonlyArray<any>>(item: LazyArbitrary<A>) => LazyArbitrary<A>' is not assignable to type '(arbitraries_0: LazyArbitrary<unknown>) => LazyArbitrary<readonly any[] | Readonly<Record<string, any>>>'.
  • [MISSING] error TS2322: Type '<A extends Readonly<Record<string, any>> | ReadonlyArray<any>>(a: A) => A' is not assignable to type '((fromA: unknown) => unknown) | ((fromA: unknown) => unknown)'.

packages/schema/dtslint/tsconfig.json

puppeteer

packages/puppeteer-core/tsconfig.json

webpack

tsconfig.types.json

@typescript-bot
Copy link
Collaborator

@rbuckton Here are the results of running the user tests comparing main and refs/pull/58243/merge:

There were infrastructure failures potentially unrelated to your change:

  • 1 instance of "Unknown failure"

Otherwise...

Everything looks good!

@jakebailey
Copy link
Member

The new flag is going to be interesting for DT where we don't actually have strict enabled (just null checks, implicit any, SFC). Maybe it's time that we just did that?

@rbuckton
Copy link
Member Author

DefinitelyTyped breaks will be addressed by DefinitelyTyped/DefinitelyTyped#69632

@jakebailey
Copy link
Member

That fixes all of them even with the flag turned on? That's the bit I was worried about; not having coverage there because DT doesn't wholesale enable strict mode.

@typescript-bot
Copy link
Collaborator

@rbuckton Here are the results of running the top 400 repos comparing main and refs/pull/58243/merge:

Something interesting changed - please have a look.

Details

discordjs/discord.js

38 of 62 projects failed to build with the old tsc and were ignored

packages/collection/tsconfig.json

packages/collection/tsconfig.eslint.json

packages/collection/tsconfig.docs.json

jupyterlab/jupyterlab

44 of 58 projects failed to build with the old tsc and were ignored

packages/ui-components/examples/simple-windowed-list/tsconfig.json

  • error TS2430: Interface 'TextIterator' incorrectly extends interface 'Iterator<string, any, unknown>'.

packages/codeeditor/tsconfig.test.json

examples/filebrowser/src/tsconfig.json

examples/console/src/tsconfig.json

nextui-org/nextui

2 of 80 projects failed to build with the old tsc and were ignored

packages/hooks/use-aria-multiselect/tsconfig.json

packages/core/react/tsconfig.json

packages/components/select/tsconfig.json

trpc/trpc

28 of 35 projects failed to build with the old tsc and were ignored

packages/server/tsconfig.json

packages/server/tsconfig.benchmark.json

packages/react-query/tsconfig.json

packages/next/tsconfig.watch.json

packages/next/tsconfig.json

packages/client/tsconfig.json

vuejs/core

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

tsconfig.build-browser.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Add a Flag Any problem can be solved by flags, except for the problem of having too many flags API Relates to the public API for TypeScript Author: Team Breaking Change Would introduce errors in existing code Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
PR Backlog
  
Not started
6 participants