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

Fix types for Object.entries/Object.fromEntries #61074

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

Conversation

nezo32
Copy link

@nezo32 nezo32 commented Jan 29, 2025

Fixes #60859

Added an optional generic type with string as the default type for the object argument in Object.entries. This makes the typing of this function “end-to-end”. For example, if Record<“value1” | “value2”, string> is passed as an argument, the output value will be [“value1” | “value2”, string][]

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Added an optional generic type with PropertyKey as the default type for the object argument in Object.fromEntries. This makes the typing of this function “end-to-end”. For example, if [ “value1” | “value2”, string ][] is passed as an argument, the output value will be { [Key in “value1” | “value2”]: string }
@nezo32
Copy link
Author

nezo32 commented Jan 29, 2025

@microsoft-github-policy-service agree

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Jan 30, 2025
@typescript-bot
Copy link
Collaborator

The TypeScript team hasn't accepted the linked issue #60859. If you can get it accepted, this PR will have a better chance of being reviewed.

@jakebailey
Copy link
Member

If the test results and self check are indicative, this seems pretty breaky.

@typescript-bot test it

@typescript-bot
Copy link
Collaborator

typescript-bot commented Feb 22, 2025

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

@typescript-bot
Copy link
Collaborator

@jakebailey
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 196,593k (± 0.06%) 196,459k (± 0.09%) ~ 196,251k 196,693k p=0.173 n=6
Parse Time 1.59s (± 1.84%) 1.58s (± 1.48%) ~ 1.55s 1.61s p=0.806 n=6
Bind Time 0.89s (± 1.70%) 0.88s (± 0.59%) ~ 0.87s 0.88s p=0.348 n=6
Check Time 11.80s (± 0.60%) 11.81s (± 1.06%) ~ 11.69s 12.00s p=0.936 n=6
Emit Time 3.35s (± 3.28%) 3.45s (± 3.47%) ~ 3.32s 3.57s p=0.126 n=6
Total Time 17.63s (± 0.46%) 17.72s (± 0.63%) ~ 17.50s 17.81s p=0.149 n=6
angular-1 - node (v18.15.0, x64)
Errors 37 40 🔻+3 (+ 8.11%) ~ ~ p=0.001 n=6
Symbols 948,488 948,574 +86 (+ 0.01%) ~ ~ p=0.001 n=6
Types 411,006 411,067 +61 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 1,224,312k (± 0.01%) 1,224,412k (± 0.00%) +101k (+ 0.01%) 1,224,379k 1,224,503k p=0.045 n=6
Parse Time 8.01s (± 1.10%) 7.98s (± 0.83%) ~ 7.91s 8.09s p=0.518 n=6
Bind Time 2.28s (± 0.60%) 2.29s (± 0.87%) ~ 2.26s 2.32s p=0.564 n=6
Check Time 37.99s (± 0.51%) 38.00s (± 0.41%) ~ 37.83s 38.15s p=0.810 n=6
Emit Time 18.35s (± 0.15%) 18.40s (± 0.55%) ~ 18.29s 18.53s p=0.573 n=6
Total Time 66.64s (± 0.37%) 66.66s (± 0.35%) ~ 66.42s 66.96s p=0.810 n=6
mui-docs - node (v18.15.0, x64)
Errors 0 0 ~ ~ ~ p=1.000 n=6
Symbols 2,347,440 2,347,957 +517 (+ 0.02%) ~ ~ p=0.001 n=6
Types 845,526 845,770 +244 (+ 0.03%) ~ ~ p=0.001 n=6
Memory used 2,120,673k (± 0.01%) 2,120,955k (± 0.01%) +283k (+ 0.01%) 2,120,800k 2,121,146k p=0.045 n=6
Parse Time 8.81s (± 1.86%) 8.78s (± 0.56%) ~ 8.70s 8.85s p=0.420 n=6
Bind Time 2.81s (± 8.15%) 2.94s (± 0.93%) ~ 2.92s 2.98s p=0.685 n=6
Check Time 87.08s (± 0.77%) 86.88s (± 0.30%) ~ 86.51s 87.21s p=1.000 n=6
Emit Time 0.20s (± 2.54%) 0.20s (± 4.95%) ~ 0.18s 0.21s p=0.386 n=6
Total Time 98.91s (± 0.77%) 98.79s (± 0.28%) ~ 98.40s 99.18s p=1.000 n=6
self-build-src - node (v18.15.0, x64)
Errors 0 10 🔻+10 (+ ∞%) ~ ~ p=0.001 n=6
Symbols 1,226,588 1,424,758 🔻+198,170 (+16.16%) ~ ~ p=0.001 n=6
Types 266,986 268,466 +1,480 (+ 0.55%) ~ ~ p=0.001 n=6
Memory used 2,357,171k (± 0.02%) 3,088,988k (± 3.12%) 🔻+731,818k (+31.05%) 3,026,265k 3,214,016k p=0.005 n=6
Parse Time 5.24s (± 0.73%) 8.53s (± 0.44%) 🔻+3.29s (+62.79%) 8.46s 8.56s p=0.005 n=6
Bind Time 1.78s (± 0.85%) 2.95s (± 0.61%) 🔻+1.17s (+66.04%) 2.92s 2.97s p=0.005 n=6
Check Time 35.25s (± 0.37%) 35.41s (± 0.44%) ~ 35.23s 35.68s p=0.128 n=6
Emit Time 3.00s (± 1.22%) 2.99s (± 1.55%) ~ 2.92s 3.04s p=0.936 n=6
Total Time 45.28s (± 0.29%) 49.89s (± 0.38%) 🔻+4.62s (+10.20%) 49.61s 50.20s p=0.005 n=6
self-build-src-public-api - node (v18.15.0, x64)
Errors 0 10 🔻+10 (+ ∞%) ~ ~ p=0.001 n=6
Symbols 1,226,588 1,424,758 🔻+198,170 (+16.16%) ~ ~ p=0.001 n=6
Types 266,986 268,466 +1,480 (+ 0.55%) ~ ~ p=0.001 n=6
Memory used 2,424,490k (± 0.02%) 3,191,634k (± 3.16%) 🔻+767,145k (+31.64%) 3,098,820k 3,284,204k p=0.005 n=6
Parse Time 5.45s (± 0.47%) 8.81s (± 0.51%) 🔻+3.36s (+61.55%) 8.76s 8.88s p=0.005 n=6
Bind Time 1.79s (± 1.36%) 2.97s (± 0.41%) 🔻+1.18s (+66.20%) 2.95s 2.98s p=0.005 n=6
Check Time 35.35s (± 0.43%) 35.37s (± 0.32%) ~ 35.20s 35.53s p=0.575 n=6
Emit Time 3.11s (± 2.64%) 3.06s (± 1.04%) ~ 3.02s 3.11s p=0.295 n=6
Total Time 45.71s (± 0.37%) 50.20s (± 0.26%) 🔻+4.50s (+ 9.84%) 50.00s 50.36s p=0.005 n=6
self-compiler - node (v18.15.0, x64)
Errors 0 4 🔻+4 (+ ∞%) ~ ~ p=0.001 n=6
Symbols 262,667 266,685 +4,018 (+ 1.53%) ~ ~ p=0.001 n=6
Types 106,849 108,059 +1,210 (+ 1.13%) ~ ~ p=0.001 n=6
Memory used 440,415k (± 0.01%) 442,614k (± 0.02%) +2,199k (+ 0.50%) 442,518k 442,746k p=0.005 n=6
Parse Time 3.53s (± 0.59%) 3.56s (± 0.86%) ~ 3.52s 3.60s p=0.146 n=6
Bind Time 1.32s (± 1.04%) 1.33s (± 0.79%) ~ 1.31s 1.34s p=0.360 n=6
Check Time 18.97s (± 0.39%) 19.04s (± 0.48%) ~ 18.95s 19.19s p=0.260 n=6
Emit Time 1.54s (± 0.86%) 1.54s (± 0.58%) ~ 1.53s 1.55s p=0.666 n=6
Total Time 25.35s (± 0.31%) 25.47s (± 0.39%) ~ 25.35s 25.64s p=0.064 n=6
ts-pre-modules - node (v18.15.0, x64)
Errors 70 70 ~ ~ ~ p=1.000 n=6
Symbols 226,113 226,113 ~ ~ ~ p=1.000 n=6
Types 94,488 94,491 +3 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 371,352k (± 0.03%) 371,386k (± 0.04%) ~ 371,270k 371,650k p=1.000 n=6
Parse Time 2.88s (± 0.90%) 2.87s (± 0.60%) ~ 2.85s 2.90s p=0.463 n=6
Bind Time 1.60s (± 1.70%) 1.59s (± 1.19%) ~ 1.57s 1.62s p=0.685 n=6
Check Time 16.47s (± 0.38%) 16.40s (± 0.39%) ~ 16.30s 16.47s p=0.065 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 20.95s (± 0.39%) 20.86s (± 0.26%) ~ 20.80s 20.95s p=0.065 n=6
vscode - node (v18.15.0, x64)
Errors 1 20 🔻+19 (+1,900.00%) ~ ~ p=0.001 n=6
Symbols 3,230,018 3,221,284 -8,734 (- 0.27%) ~ ~ p=0.001 n=6
Types 1,095,648 1,089,855 -5,793 (- 0.53%) ~ ~ p=0.001 n=6
Memory used 3,306,425k (± 0.01%) 3,299,598k (± 0.01%) -6,827k (- 0.21%) 3,298,959k 3,299,825k p=0.005 n=6
Parse Time 14.25s (± 0.21%) 14.31s (± 0.52%) ~ 14.22s 14.39s p=0.260 n=6
Bind Time 4.57s (± 0.38%) 4.55s (± 0.79%) ~ 4.50s 4.59s p=0.627 n=6
Check Time 87.73s (± 0.36%) 87.66s (± 1.37%) ~ 86.02s 89.63s p=0.575 n=6
Emit Time 28.06s (± 2.68%) 27.45s (± 0.88%) ~ 27.09s 27.84s p=0.298 n=6
Total Time 134.61s (± 0.69%) 133.97s (± 0.94%) ~ 132.33s 136.13s p=0.378 n=6
webpack - node (v18.15.0, x64)
Errors 2 2 ~ ~ ~ p=1.000 n=6
Symbols 293,866 293,866 ~ ~ ~ p=1.000 n=6
Types 119,628 119,634 +6 (+ 0.01%) ~ ~ p=0.001 n=6
Memory used 446,890k (± 0.01%) 446,967k (± 0.01%) +77k (+ 0.02%) 446,913k 447,006k p=0.013 n=6
Parse Time 3.29s (± 0.33%) 3.30s (± 0.49%) ~ 3.28s 3.32s p=0.188 n=6
Bind Time 1.47s (± 1.00%) 1.48s (± 0.79%) ~ 1.46s 1.49s p=0.458 n=6
Check Time 15.61s (± 0.28%) 15.66s (± 0.34%) ~ 15.57s 15.72s p=0.172 n=6
Emit Time 0.00s 0.00s ~ ~ ~ p=1.000 n=6
Total Time 20.37s (± 0.23%) 20.44s (± 0.27%) ~ 20.36s 20.51s p=0.054 n=6
xstate-main - node (v18.15.0, x64)
Errors 5 5 ~ ~ ~ p=1.000 n=6
Symbols 559,094 559,058 -36 (- 0.01%) ~ ~ p=0.001 n=6
Types 187,011 187,015 +4 (+ 0.00%) ~ ~ p=0.001 n=6
Memory used 496,267k (± 0.03%) 496,144k (± 0.01%) -124k (- 0.02%) 496,095k 496,179k p=0.013 n=6
Parse Time 3.43s (± 0.44%) 3.44s (± 0.75%) ~ 3.40s 3.47s p=0.568 n=6
Bind Time 1.20s (± 0.63%) 1.20s (± 0.97%) ~ 1.19s 1.22s p=0.396 n=6
Check Time 19.65s (± 0.66%) 19.69s (± 0.43%) ~ 19.60s 19.81s p=0.521 n=6
Emit Time 0.00s (±244.70%) 0.00s ~ ~ ~ p=0.405 n=6
Total Time 24.28s (± 0.48%) 24.32s (± 0.37%) ~ 24.23s 24.44s p=0.378 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

Developer Information:

Download Benchmarks

@typescript-bot
Copy link
Collaborator

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

Everything looks the same!

You can check the log here.

@typescript-bot
Copy link
Collaborator

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

Something interesting changed - please have a look.

Details

azure-sdk

/mnt/ts_downloads/_/m/azure-sdk/build.sh

  • [NEW] error TS2339: Property 'predicate' does not exist on type 'Accumulator<unknown> | undefined'.
    • /mnt/ts_downloads/_/m/azure-sdk/src/util/typescript/accumulator.ts(81,25)
  • [NEW] error TS2339: Property 'select' does not exist on type 'Accumulator<unknown> | undefined'.
    • /mnt/ts_downloads/_/m/azure-sdk/src/util/typescript/accumulator.ts(81,36)

puppeteer

tools/mocha-runner/tsconfig.json

packages/puppeteer-core/tsconfig.json

@typescript-bot
Copy link
Collaborator

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

Something interesting changed - please have a look.

Details

actualbudget/actual

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

tsconfig.json

alan2207/bulletproof-react

apps/react-vite/tsconfig.json

apps/nextjs-pages/tsconfig.json

apps/nextjs-app/tsconfig.json

continuedev/continue

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

extensions/vscode/tsconfig.json

  • error TS2322: Type '{ name: keyof Object; version: Function | (() => string) | (() => Object) | (() => string) | ((v: PropertyKey) => boolean) | ((v: Object) => boolean) | ((v: PropertyKey) => boolean); packageFile: PackageFilePathAndName; language: string; }[]' is not assignable to type 'ParsedPackageInfo[]'.

core/tsconfig.npm.json

  • error TS2322: Type '{ name: keyof Object; version: Function | (() => string) | (() => Object) | (() => string) | ((v: PropertyKey) => boolean) | ((v: Object) => boolean) | ((v: PropertyKey) => boolean); packageFile: PackageFilePathAndName; language: string; }[]' is not assignable to type 'ParsedPackageInfo[]'.

core/tsconfig.json

  • error TS2322: Type '{ name: keyof Object; version: Function | (() => string) | (() => Object) | (() => string) | ((v: PropertyKey) => boolean) | ((v: Object) => boolean) | ((v: PropertyKey) => boolean); packageFile: PackageFilePathAndName; language: string; }[]' is not assignable to type 'ParsedPackageInfo[]'.

binary/tsconfig.json

  • error TS2322: Type '{ name: keyof Object; version: Function | (() => string) | (() => Object) | (() => string) | ((v: PropertyKey) => boolean) | ((v: Object) => boolean) | ((v: PropertyKey) => boolean); packageFile: PackageFilePathAndName; language: string; }[]' is not assignable to type 'ParsedPackageInfo[]'.

ether/etherpad-lite

src/tsconfig.json

FlowiseAI/Flowise

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

packages/components/tsconfig.json

gothinkster/realworld

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

apps/documentation/tsconfig.json

  • error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ "\0virtual:starlight/components/Head": "virtual:starlight/components/Head" | "virtual:starlight/components/ThemeProvider" | "virtual:starlight/components/SkipLink" | "virtual:starlight/components/PageFrame" | ... 28 more ... | "virtual:starlight/collection-config"; ... 31 more ...; "\0virtual:starlight/collection-...'.
    • file:///mnt/ts_downloads/_/m/realworld/node_modules/.pnpm/@astrojs+starlight@0.26.4_astro@4.15.12/node_modules/@astrojs/starlight/integrations/virtual-user-config.ts#L80
  • error TS7053: Element implicitly has an 'any' type because expression of type 'any' can't be used to index type '{ "virtual:starlight/components/Head": string; "virtual:starlight/components/ThemeProvider": string; "virtual:starlight/components/SkipLink": string; "virtual:starlight/components/PageFrame": string; ... 28 more ...; 'virtual:starlight/collection-config': string; }'.
    • file:///mnt/ts_downloads/_/m/realworld/node_modules/.pnpm/@astrojs+starlight@0.26.4_astro@4.15.12/node_modules/@astrojs/starlight/integrations/virtual-user-config.ts#L81
  • error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ cs: { 'skipLink.label': string; 'search.label': string; 'search.ctrlKey': string; 'search.cancelLabel': string; 'search.devWarning': string; 'themeSelect.accessibleLabel': string; 'themeSelect.dark': string; ... 32 more ...; 'expressiveCode.terminalWindowFallbackTitle'?: string | undefined; }; ... 26 more ...; sk:...'.
    • file:///mnt/ts_downloads/_/m/realworld/node_modules/.pnpm/@astrojs+starlight@0.26.4_astro@4.15.12/node_modules/@astrojs/starlight/utils/createTranslationSystem.ts#L17
    • file:///mnt/ts_downloads/_/m/realworld/node_modules/.pnpm/@astrojs+starlight@0.26.4_astro@4.15.12/node_modules/@astrojs/starlight/utils/createTranslationSystem.ts#L17
    • file:///mnt/ts_downloads/_/m/realworld/node_modules/.pnpm/@astrojs+starlight@0.26.4_astro@4.15.12/node_modules/@astrojs/starlight/utils/createTranslationSystem.ts#L38
    • file:///mnt/ts_downloads/_/m/realworld/node_modules/.pnpm/@astrojs+starlight@0.26.4_astro@4.15.12/node_modules/@astrojs/starlight/utils/createTranslationSystem.ts#L38

mattermost-community/focalboard

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

import/trello/tsconfig.json

  • error TS2339: Property 'timestamp' does not exist on type '{ language: string | null; theme: string | null; lastTeamId: string | null; lastBoardId: string | null; lastViewId: string | null; "emoji-mart.skin": string | null; "emoji-mart.last": string | null; ... 4 more ...; nameFormat: string | null; }'.

import/todoist/tsconfig.json

  • error TS2339: Property 'timestamp' does not exist on type '{ language: string | null; theme: string | null; lastTeamId: string | null; lastBoardId: string | null; lastViewId: string | null; "emoji-mart.skin": string | null; "emoji-mart.last": string | null; ... 4 more ...; nameFormat: string | null; }'.

import/notion/tsconfig.json

  • error TS2339: Property 'timestamp' does not exist on type '{ language: string | null; theme: string | null; lastTeamId: string | null; lastBoardId: string | null; lastViewId: string | null; "emoji-mart.skin": string | null; "emoji-mart.last": string | null; ... 4 more ...; nameFormat: string | null; }'.

import/nextcloud-deck/tsconfig.json

  • error TS2339: Property 'timestamp' does not exist on type '{ language: string | null; theme: string | null; lastTeamId: string | null; lastBoardId: string | null; lastViewId: string | null; "emoji-mart.skin": string | null; "emoji-mart.last": string | null; ... 4 more ...; nameFormat: string | null; }'.

import/jira/tsconfig.json

  • error TS2339: Property 'timestamp' does not exist on type '{ language: string | null; theme: string | null; lastTeamId: string | null; lastBoardId: string | null; lastViewId: string | null; "emoji-mart.skin": string | null; "emoji-mart.last": string | null; ... 4 more ...; nameFormat: string | null; }'.

import/asana/tsconfig.json

  • error TS2339: Property 'timestamp' does not exist on type '{ language: string | null; theme: string | null; lastTeamId: string | null; lastBoardId: string | null; lastViewId: string | null; "emoji-mart.skin": string | null; "emoji-mart.last": string | null; ... 4 more ...; nameFormat: string | null; }'.

microsoft/vscode

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

src/tsconfig.tsec.json

src/tsconfig.monaco.json

neoclide/coc.nvim

tsconfig.json

openai-translator/openai-translator

tsconfig.json

outline/outline

tsconfig.json

refined-github/refined-github

tsconfig.json

  • error TS7053: Element implicitly has an 'any' type because expression of type '`feature:${string}`' can't be used to index type '{ actionUrl: string; customCSS: string; personalToken: string; logging: boolean; logHTTP: boolean; } & { [x: `feature:${FeatureID}`]: boolean; }'.
  • error TS7053: Element implicitly has an 'any' type because expression of type '"feature:scrollable-code-and-blockquote" | "feature:separate-draft-pr-button" | "feature:prevent-pr-commit-link-loss" | "feature:remove-projects-tab" | "feature:remove-unused-repo-tabs" | ... 31 more ... | "feature:highlight-collaborators-and-own-conversations"' can't be used to index type '{ actionUrl: string; customCSS: string; personalToken: string; logging: boolean; logHTTP: boolean; } & { [x: `feature:${FeatureID}`]: boolean; }'.
  • error TS7053: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type '{ actionUrl: string; customCSS: string; personalToken: string; logging: boolean; logHTTP: boolean; } & { [x: `feature:${FeatureID}`]: boolean; }'.

shadcn-ui/ui

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

packages/shadcn/tsconfig.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Status: Not started
3 participants