Skip to content

Try not allowing string iteration #59683

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

Closed
wants to merge 1 commit into from

Conversation

RyanCavanaugh
Copy link
Member

Trial for #59676 to see what happens in real world code

@typescript-bot typescript-bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Aug 19, 2024
@RyanCavanaugh
Copy link
Member Author

@typescript-bot run top800

@jakebailey
Copy link
Member

@typescript-bot test top800

@typescript-bot
Copy link
Collaborator

typescript-bot commented Aug 19, 2024

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

Command Status Results
test top800 ✅ Started 👀 Results

@MichaelMitchell-at
Copy link
Contributor

We actually had an incident related to this recently and patched String a few weeks ago!

@jakebailey
Copy link
Member

Oh hey, the self test is actually catching a bug:

Error: src/server/editorServices.ts(4962,25): error TS2769: No overload matches this call.
  Overload 1 of 2, '(iterable?: Iterable<string> | null | undefined): Set<string>', gave the following error.
    Argument of type 'string' is not assignable to parameter of type 'Iterable<string>'.
  Overload 2 of 2, '(values?: readonly string[] | null | undefined): Set<string>', gave the following error.
    Argument of type 'string' is not assignable to parameter of type 'readonly string[]'.

image

@jakebailey
Copy link
Member

The rest are strange string manipulation stuff which feels moderately dubious when it comes to "properly" handling indexes:

Error: src/harness/fourslashImpl.ts(2594,43): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Iterable<unknown>'.
Error: src/harness/fourslashImpl.ts(2595,38): error TS18046: 'char' is of type 'unknown'.
Error: src/harness/fourslashImpl.ts(2603,51): error TS2345: Argument of type 'string' is not assignable to parameter of type 'Iterable<unknown>'.
Error: src/harness/fourslashImpl.ts(2603,69): error TS2345: Argument of type '(char: string) => boolean' is not assignable to parameter of type '(value: unknown, index: number, obj: unknown[]) => unknown'.
  Types of parameters 'char' and 'value' are incompatible.
    Type 'unknown' is not assignable to type 'string'.
Error: src/harness/fourslashImpl.ts(2604,56): error TS2345: Argument of type 'unknown[]' is not assignable to parameter of type 'readonly string[]'.
  Type 'unknown' is not assignable to type 'string'.
Error: src/harness/fourslashImpl.ts(2604,69): error TS[23](https://github.com/microsoft/TypeScript/actions/runs/10457724694/job/28958003929?pr=59683#step:7:24)45: Argument of type 'string' is not assignable to parameter of type 'Iterable<unknown>'.
Error in build-src in 23s
Error: Process exited with code: 2
Completed build-src with errors in 23s

@MichaelMitchell-at
Copy link
Contributor

MichaelMitchell-at commented Aug 19, 2024

Oh hey, the self test is actually catching a bug:

This is almost the exact same kind of bug we had. In our case we were spreading a string instead of an array of string.

@MichaelMitchell-at
Copy link
Contributor

MichaelMitchell-at commented Aug 19, 2024

Oh hey, the self test is actually catching a bug:

This is almost the exact same kind of bug we had. In our case we were spreading a string instead of an array of string.

Also fun times, if you have an argument spread that's too large you may get a stack overflow

@typescript-bot
Copy link
Collaborator

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

Something interesting changed - please have a look.

Details

adobe/react-spectrum

9 of 15 projects failed to build with the old tsc and were ignored

packages/@spectrum-icons/illustrations/tsconfig.types.json

ben-rogerson/twin.macro

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

tsconfig.json

bitwarden/clients

21 of 57 projects failed to build with the old tsc and were ignored

libs/vault/tsconfig.spec.json

libs/vault/tsconfig.json

libs/tools/send/send-ui/tsconfig.spec.json

libs/tools/send/send-ui/tsconfig.json

libs/tools/export/vault-export/vault-export-ui/tsconfig.spec.json

libs/tools/export/vault-export/vault-export-ui/tsconfig.json

libs/importer/tsconfig.spec.json

libs/importer/tsconfig.json

libs/auth/tsconfig.spec.json

libs/auth/tsconfig.json

Chocobozzz/PeerTube

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

packages/types-generator/tsconfig.types.json

  • error TS2322: Type '{ defaultSrc: string[]; connectSrc: string[]; mediaSrc: string[]; fontSrc: string[]; imgSrc: string[]; scriptSrc: string[]; scriptSrcAttr: string[]; styleSrc: string[]; objectSrc: string[]; formAction: string[]; ... 4 more ...; workerSrc: string[]; } & (({ ...; } | { ...; }) & ({ ...; } | { ...; }))' is not assignable to type 'Record<string, Iterable<ContentSecurityPolicyDirectiveValue> | unique symbol>'.
  • error TS2322: Type '({ defaultSrc: string[]; connectSrc: string[]; mediaSrc: string[]; fontSrc: string[]; imgSrc: string[]; scriptSrc: string[]; scriptSrcAttr: string[]; styleSrc: string[]; objectSrc: string[]; formAction: string[]; ... 4 more ...; workerSrc: string[]; } & (({ ...; } | { ...; }) & ({ ...; } | { ...; }))) & { ...; }' is not assignable to type 'Record<string, Iterable<ContentSecurityPolicyDirectiveValue> | unique symbol>'.

packages/tests/tsconfig.json

  • error TS2322: Type '{ defaultSrc: string[]; connectSrc: string[]; mediaSrc: string[]; fontSrc: string[]; imgSrc: string[]; scriptSrc: string[]; scriptSrcAttr: string[]; styleSrc: string[]; objectSrc: string[]; formAction: string[]; ... 4 more ...; workerSrc: string[]; } & (({ ...; } | { ...; }) & ({ ...; } | { ...; }))' is not assignable to type 'Record<string, Iterable<ContentSecurityPolicyDirectiveValue> | unique symbol>'.
  • error TS2322: Type '({ defaultSrc: string[]; connectSrc: string[]; mediaSrc: string[]; fontSrc: string[]; imgSrc: string[]; scriptSrc: string[]; scriptSrcAttr: string[]; styleSrc: string[]; objectSrc: string[]; formAction: string[]; ... 4 more ...; workerSrc: string[]; } & (({ ...; } | { ...; }) & ({ ...; } | { ...; }))) & { ...; }' is not assignable to type 'Record<string, Iterable<ContentSecurityPolicyDirectiveValue> | unique symbol>'.

continuedev/continue

8 of 9 projects failed to build with the old tsc and were ignored

binary/tsconfig.json

curlconverter/curlconverter

tsconfig.json

desktop/desktop

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

tsconfig.json

discordjs/discord.js

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

apps/website/tsconfig.json

apps/website/tsconfig.eslint.json

dream-num/univer

39 of 57 projects failed to build with the old tsc and were ignored

packages/sheets-thread-comment-base/tsconfig.json

packages/sheets-sort/tsconfig.json

packages/sheets-hyper-link/tsconfig.json

packages/sheets-filter/tsconfig.json

packages/sheets/tsconfig.json

packages/engine-formula/tsconfig.json

packages/data-validation/tsconfig.json

ether/etherpad-lite

src/tsconfig.json

faker-js/faker

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

tsconfig.build.json

getumbrel/llama-gpt

ui/tsconfig.json

gitkraken/vscode-gitlens

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

src/webviews/apps/tsconfig.json

hexojs/hexo

tsconfig.json

immich-app/immich

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

server/tsconfig.json

server/tsconfig.build.json

immutable-js/immutable-js

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

__tests__/tsconfig.json

javascript-obfuscator/javascript-obfuscator

tsconfig.json

test/tsconfig.test.json

src/tsconfig.typings.json

src/tsconfig.browser.json

jhipster/generator-jhipster

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

tsconfig.types.json

tsconfig.json

jupyterlab/jupyterlab

46 of 59 projects failed to build with the old tsc and were ignored

examples/filebrowser/src/tsconfig.json

examples/console/src/tsconfig.json

kysely-org/kysely

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

tsconfig.json

tsconfig-cjs.json

mapbox/mapbox-gl-js

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

tsconfig.json

microsoft/azuredatastudio

11 of 67 projects failed to build with the old tsc and were ignored

extensions/markdown-language-features/tsconfig.json

extensions/markdown-language-features/tsconfig.browser.json

extensions/git/tsconfig.json

microsoft/inshellisense

tsconfig.json

microsoft/playwright

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

packages/recorder/tsconfig.json

microsoft/vscode-extension-samples

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

drop-on-document/tsconfig.json

microsoft/vscode

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

src/tsconfig.tsec.json

src/tsconfig.monaco.json

src/tsconfig.json

extensions/markdown-language-features/tsconfig.json

extensions/markdown-language-features/tsconfig.browser.json

extensions/git/tsconfig.json

build/tsconfig.build.json

  • error TS2488: Type 'string | string[]' must have a '[Symbol.iterator]()' method that returns an iterator.

motion-canvas/motion-canvas

14 of 18 projects failed to build with the old tsc and were ignored

packages/core/tsconfig.json

packages/core/tsconfig.build.json

mui/material-ui

23 of 83 projects failed to build with the old tsc and were ignored

docs/tsconfig.json

neoclide/coc.nvim

tsconfig.json

NG-ZORRO/ng-zorro-antd

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

components/tsconfig.spec.json

nodejs/nodejs.org

apps/site/tsconfig.json

pillarjs/path-to-regexp

tsconfig.json

  • error TS2488: Type 'string' must have a '[Symbol.iterator]()' method that returns an iterator.

tsconfig.build.json

  • error TS2488: Type 'string' must have a '[Symbol.iterator]()' method that returns an iterator.

pixijs/pixijs

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

tsconfig.types.json

pubkey/rxdb

8 of 11 projects failed to build with the old tsc and were ignored

tsconfig.json

config/tsconfig.types.json

raineorshine/npm-check-updates

tsconfig.json

@typescript-bot
Copy link
Collaborator

@jakebailey Here are some more interesting changes from running the top 800 repos suite

Details

reduxjs/redux-toolkit

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

packages/toolkit/tsconfig.json

refined-github/refined-github

tsconfig.json

shadcn-ui/ui

7 of 9 projects failed to build with the old tsc and were ignored

packages/cli/tsconfig.json

  • error TS2345: Argument of type 'String' is not assignable to parameter of type 'string | ArrayBufferView | Iterable<string | ArrayBufferView> | AsyncIterable<string | ArrayBufferView> | Stream'.

sindresorhus/got

tsconfig.json

tusen-ai/naive-ui

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

src/tsconfig.demo.json

vadimdemedes/ink

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

tsconfig.json

vscode-neovim/vscode-neovim

tsconfig.json

VSCodeVim/Vim

tsconfig.json

wandb/openui

frontend/tsconfig.json

yoavbls/pretty-ts-errors

tsconfig.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants