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

lib Fix Part 6/6 – Array.isArray #50454

Closed

Conversation

graphemecluster
Copy link
Contributor

@graphemecluster graphemecluster commented Aug 25, 2022

General Information

PR separated out from #49855, because there might be some members expecting smaller PRs. As mentioned in the comments from the big PR, whether to review a single, large PR or 6 smaller PRs is up to the TypeScript Team to decide. I couldn't have found a better way for this; hopefully this will not bring any trouble to the Team.

This PR partially fixes #49773.
For details and the track list about the changes, please see #49773.

Part 6/6, Array.isArray

Fix #17002
Actually fix #32497
Fix #33700
Fix #41808
Actually fix #43247

This PR supersedes #48228 as it fails to address readonly number[].
I am confident to this solution.
Edit: I guess I must retract this. See the results below. 😔

@typescript-bot typescript-bot added For Backlog Bug PRs that fix a backlog bug For Milestone Bug PRs that fix a bug with a specific milestone labels Aug 25, 2022
@sandersn sandersn added this to Not started in PR Backlog Sep 2, 2022
@sandersn
Copy link
Member

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

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2022

Heya @sandersn, I've started to run the diff-based top-repos suite on this PR at f660c25. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2022

Heya @sandersn, I've started to run the parallelized Definitely Typed test suite on this PR at f660c25. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Sep 13, 2022

Heya @sandersn, I've started to run the diff-based user code test suite on this PR at f660c25. You can monitor the build here.

Update: The results are in!

@sandersn
Copy link
Member

We tried this a couple of years ago; I don't remember what problems it ran into but I don't think #48228 was the only attempt.

@sandersn sandersn self-assigned this Sep 13, 2022
@sandersn sandersn requested review from sandersn and DanielRosenwasser and removed request for sandersn September 13, 2022 23:25
@sandersn sandersn moved this from Not started to Waiting on reviewers in PR Backlog Sep 13, 2022
@typescript-bot
Copy link
Collaborator

@sandersn Here are the results of running the user test suite comparing main and refs/pull/50454/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.json

  • [NEW] error TS2339: Property 'length' does not exist on type 'T[P] extends any ? Extract<true extends false & T[P] ? any[] : T[P] extends readonly any[] ? T[P] : T[P] extends string ? never : T[P] extends ArrayLike<...> | Iterable<...> ? U[] : unknown[], T[P]> : never'.
  • [NEW] error TS2339: Property 'slice' does not exist on type 'T[P] extends any ? Extract<true extends false & T[P] ? any[] : T[P] extends readonly any[] ? T[P] : T[P] extends string ? never : T[P] extends ArrayLike<...> | Iterable<...> ? U[] : unknown[], T[P]> : never'.

tsconfig.types.json

  • [NEW] error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type '(T[P] & null extends any ? Extract<T[P] & null extends readonly any[] ? T[P] & null : T[P] & null extends string ? never : T[P] & null extends ArrayLike<...> | Iterable<...> ? U[] : unknown[], T[P] & null> : never) | (T[P] & {} extends any ? Extract<...> : never)'.
  • [NEW] error TS2345: Argument of type 'unknown' is not assignable to parameter of type 'Object'.
  • [MISSING] error TS2345: Argument of type '{ _index: number; type: string; constructor?: Function | undefined; toString?: (() => string) | undefined; toLocaleString?: (() => string) | undefined; valueOf?: (() => Object) | undefined; hasOwnProperty?: ((v: PropertyKey) => boolean) | undefined; isPrototypeOf?: ((v: Object) => boolean) | undefined; propertyIsEnu...' is not assignable to parameter of type 'Object'.

@typescript-bot
Copy link
Collaborator

@sandersn Here are the results of running the top-repos suite comparing main and refs/pull/50454/merge:

Something interesting changed - please have a look.

Details

cheeriojs/cheerio

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

tsconfig.json

  • error TS2322: Type 'ChildNode[] | (S extends any ? Extract<true extends false & S ? any[] : S extends readonly any[] ? S : S extends string ? never : S extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], S> : never) | T[] | (NonNullable<...> extends any ? Extract<...> : never) | undefined' is not assignable to type 'AnyNode[] | undefined'.

conwnet/github1s

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

extensions/github1s/tsconfig.json

  • error TS2322: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)' is not assignable to type 'T[]'.

excalidraw/excalidraw

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

tsconfig-types.json

  • error TS2322: Type 'readonly (readonly [number, number])[] | number[][]' is not assignable to type 'readonly (readonly [number, number])[]'.

graphql/graphql-js

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

tsconfig.json

JedWatson/react-select

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

packages/react-select/src/tests/tsconfig.json

  • error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type '(OnChangeValue<Option, IsMulti> extends any ? Extract<true extends false & OnChangeValue<Option, IsMulti> ? any[] : OnChangeValue<...> extends readonly any[] ? OnChangeValue<...> : OnChangeValue<...> extends string ? never : OnChangeValue<...> extends ArrayLike<...> | Iterable<...> ? U[] : unknown[], OnChangeValue<....'.
  • error TS2339: Property 'length' does not exist on type '(OnChangeValue<Option, IsMulti> extends any ? Extract<true extends false & OnChangeValue<Option, IsMulti> ? any[] : OnChangeValue<...> extends readonly any[] ? OnChangeValue<...> : OnChangeValue<...> extends string ? never : OnChangeValue<...> extends ArrayLike<...> | Iterable<...> ? U[] : unknown[], OnChangeValue<....'.

microsoft/playwright

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

packages/html-reporter/tsconfig.json

  • error TS2322: Type 'string | string[] | ({ name?: NameOrSegments | undefined; } & T extends any ? Extract<true extends false & { name?: NameOrSegments | undefined; } & T ? any[] : { ...; } & T extends readonly any[] ? { ...; } & T : { ...; } & T extends string ? never : { ...; } & T extends ArrayLike<...> | Iterable<...> ? U[] : unknow...' is not assignable to type 'NameOrSegments | undefined'.

microsoft/vscode

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

extensions/ipynb/tsconfig.json

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

extensions/markdown-language-features/tsconfig.json

extensions/vscode-colorize-tests/tsconfig.json

src/tsconfig.json

src/tsconfig.monaco.json

  • error TS2322: Type 'any[] | unknown[]' is not assignable to type '(HTMLElement | Record<string, HTMLElement>)[] | undefined'.
  • error TS2345: Argument of type 'unknown' is not assignable to parameter of type 'string'.
  • error TS2571: Object is of type 'unknown'.
  • error TS2322: Type '{ data: { label: unknown; score: FuzzyScore; }; visibility: TreeVisibility.Visible | TreeVisibility.Recurse; }' is not assignable to type 'TreeFilterResult<FuzzyScore | LabelFuzzyScore>'.
  • error TS2339: Property 'map' does not exist on type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)'.
  • error TS2322: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)' is not assignable to type 'T[]'.

src/tsconfig.tsec.json

mobxjs/mobx

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

packages/mobx/tsconfig.json

neoclide/coc.nvim

tsconfig.json

  • error TS2339: Property 'length' does not exist on type 'T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never'.
  • error TS2322: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)' is not assignable to type 'T[]'.

pnpm/pnpm

119 of 120 projects failed to build with the old tsc and were ignored

packages/pnpm/tsconfig.json

prisma/prisma

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

packages/engines/tsconfig.build.json

react-hook-form/react-hook-form

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

tsconfig.json

ReactiveX/rxjs

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

src/tsconfig.cjs.spec.json

  • error TS2322: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never) | (O extends any ? Extract<...> : never)' is not assignable to type 'T[]'.
  • error TS2322: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)' is not assignable to type 'T[]'.
  • error TS2548: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator.

src/tsconfig.esm5.rollup.json

  • error TS2322: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never) | (O extends any ? Extract<...> : never)' is not assignable to type 'T[]'.
  • error TS2322: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)' is not assignable to type 'T[]'.
  • error TS2548: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator.

src/tsconfig.types.json

  • error TS2322: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never) | (O extends any ? Extract<...> : never)' is not assignable to type 'T[]'.
  • error TS2488: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)' must have a '[Symbol.iterator]()' method that returns an iterator.
  • error TS2322: Type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)' is not assignable to type 'T[]'.

refined-github/refined-github

tsconfig.json

  • error TS2322: Type 'Item[] | (Item extends any ? Extract<true extends false & Item ? any[] : Item extends readonly any[] ? Item : Item extends string ? never : Item extends ArrayLike<...> | Iterable<...> ? U[] : unknown[], Item> : never)' is not assignable to type 'Item[]'.

statelyai/xstate

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

packages/xstate-inspect/tsconfig.json

packages/xstate-test/tsconfig.json

vercel/hyper

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

tsconfig.json

  • error TS2339: Property 'reduce' does not exist on type 'T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never'.

vuejs/vue

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

tsconfig.json

  • error TS2339: Property 'indexOf' does not exist on type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)'.

wenyan-lang/wenyan

tsconfig.json

withfig/autocomplete

tsconfig.json

  • error TS2339: Property 'at' does not exist on type 'T[] | (T extends any ? Extract<true extends false & T ? any[] : T extends readonly any[] ? T : T extends string ? never : T extends ArrayLike<infer U> | Iterable<...> ? U[] : unknown[], T> : never)'.

@graphemecluster
Copy link
Contributor Author

That's bad; it seems that the checker really hate T extends readonly any[] ? T that line.

@graphemecluster
Copy link
Contributor Author

graphemecluster commented Sep 15, 2022

It seems that I can't use the TypeScript bot, @sandersn please help me run the test suite again.

@graphemecluster graphemecluster changed the title lib Types and Documentations Fix, Part 6/6 lib Fix Part 6/6 – Array.isArray Oct 9, 2022
@sandersn
Copy link
Member

@typescript-bot run dt
@typescript-bot test top100
@typescript-bot user test this
@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 12, 2022

Heya @sandersn, I've started to run the parallelized Definitely Typed test suite on this PR at 2149ae6. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 12, 2022

Heya @sandersn, I've started to run the diff-based top-repos suite on this PR at 2149ae6. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 12, 2022

Heya @sandersn, I've started to run the diff-based user code test suite on this PR at 2149ae6. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 12, 2022

Heya @sandersn, I've started to run the abridged perf test suite on this PR at 2149ae6. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

@sandersn Here are the results of running the user test suite comparing main and refs/pull/50454/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.json

tsconfig.types.json

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..50454

Metric main 50454 Delta Best Worst
Angular - node (v16.17.1, x64)
Memory used 352,334k (± 0.02%) 352,630k (± 0.02%) +296k (+ 0.08%) 352,386k 352,736k
Parse Time 1.89s (± 0.46%) 1.90s (± 1.08%) +0.00s (+ 0.16%) 1.86s 1.96s
Bind Time 0.74s (± 0.78%) 0.75s (± 0.66%) +0.00s (+ 0.40%) 0.74s 0.76s
Check Time 5.69s (± 0.73%) 5.65s (± 0.33%) -0.04s (- 0.70%) 5.62s 5.69s
Emit Time 6.08s (± 0.66%) 6.08s (± 0.67%) -0.00s (- 0.08%) 5.97s 6.19s
Total Time 14.41s (± 0.57%) 14.37s (± 0.38%) -0.04s (- 0.31%) 14.20s 14.48s
Compiler-Unions - node (v16.17.1, x64)
Memory used 198,279k (± 0.57%) 198,700k (± 0.61%) +421k (+ 0.21%) 197,286k 200,796k
Parse Time 0.79s (± 0.87%) 0.78s (± 0.71%) -0.00s (- 0.38%) 0.77s 0.80s
Bind Time 0.45s (± 1.09%) 0.45s (± 0.89%) -0.00s (- 0.66%) 0.44s 0.46s
Check Time 6.50s (± 0.50%) 6.51s (± 0.38%) +0.00s (+ 0.06%) 6.46s 6.57s
Emit Time 2.31s (± 1.09%) 2.30s (± 0.71%) -0.01s (- 0.43%) 2.26s 2.34s
Total Time 10.05s (± 0.50%) 10.04s (± 0.35%) -0.01s (- 0.10%) 9.95s 10.12s
Monaco - node (v16.17.1, x64)
Memory used 331,133k (± 0.02%) 331,125k (± 0.01%) -8k (- 0.00%) 331,077k 331,202k
Parse Time 1.42s (± 0.37%) 1.43s (± 0.52%) +0.01s (+ 0.42%) 1.41s 1.45s
Bind Time 0.69s (± 0.86%) 0.69s (± 0.75%) -0.00s (- 0.43%) 0.68s 0.70s
Check Time 5.47s (± 0.55%) 5.48s (± 0.50%) +0.01s (+ 0.15%) 5.44s 5.54s
Emit Time 3.26s (± 0.55%) 3.26s (± 0.79%) +0.00s (+ 0.06%) 3.23s 3.32s
Total Time 10.85s (± 0.44%) 10.86s (± 0.39%) +0.01s (+ 0.13%) 10.78s 10.97s
TFS - node (v16.17.1, x64)
Memory used 294,050k (± 0.02%) 294,087k (± 0.01%) +37k (+ 0.01%) 294,031k 294,129k
Parse Time 1.22s (± 1.53%) 1.23s (± 1.09%) +0.01s (+ 0.49%) 1.20s 1.26s
Bind Time 0.64s (± 0.97%) 0.64s (± 0.63%) 0.00s ( 0.00%) 0.63s 0.65s
Check Time 5.12s (± 0.44%) 5.13s (± 0.55%) +0.01s (+ 0.18%) 5.08s 5.20s
Emit Time 3.47s (± 0.64%) 3.49s (± 0.71%) +0.02s (+ 0.49%) 3.43s 3.55s
Total Time 10.45s (± 0.42%) 10.48s (± 0.47%) +0.03s (+ 0.31%) 10.34s 10.56s
material-ui - node (v16.17.1, x64)
Memory used 439,350k (± 0.01%) 439,362k (± 0.01%) +12k (+ 0.00%) 439,296k 439,416k
Parse Time 1.72s (± 1.24%) 1.73s (± 0.96%) +0.01s (+ 0.47%) 1.69s 1.76s
Bind Time 0.54s (± 0.69%) 0.54s (± 0.55%) +0.01s (+ 1.31%) 0.54s 0.55s
Check Time 12.52s (± 0.62%) 12.65s (± 0.75%) +0.13s (+ 1.00%) 12.50s 12.85s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 14.78s (± 0.53%) 14.92s (± 0.63%) +0.14s (+ 0.94%) 14.76s 15.11s
xstate - node (v16.17.1, x64)
Memory used 554,310k (± 0.02%) 555,844k (± 0.02%) +1,534k (+ 0.28%) 555,677k 556,243k
Parse Time 2.31s (± 0.28%) 2.30s (± 0.36%) -0.00s (- 0.17%) 2.29s 2.32s
Bind Time 0.89s (± 1.49%) 0.88s (± 1.37%) -0.01s (- 0.67%) 0.87s 0.93s
Check Time 1.43s (± 0.92%) 1.47s (± 0.69%) +0.04s (+ 3.01%) 1.45s 1.50s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 4.70s (± 0.23%) 4.74s (± 0.27%) +0.04s (+ 0.87%) 4.71s 4.76s
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-126-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current 50454 10
Baseline main 10

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

@sandersn Here are the results of running the top-repos suite comparing main and refs/pull/50454/merge:

Something interesting changed - please have a look.

Details

cheeriojs/cheerio

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

tsconfig.json

  • error TS2322: Type 'ChildNode[] | (S extends any ? Extract<(true extends false & S ? any : S extends string | readonly any[] ? unknown : S extends ArrayLike<infer U> | Iterable<...> ? U : unknown)[], S> | Extract<...> : never) | T[] | (NonNullable<...> extends any ? Extract<...> | Extract<...> : never) | undefined' is not assignable to type 'AnyNode[] | undefined'.

conwnet/github1s

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

extensions/github1s/tsconfig.json

  • error TS2322: Type 'T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<infer U> ? U : unknown)[], T> | Extract<...> : never)' is not assignable to type 'T[]'.

excalidraw/excalidraw

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

tsconfig-types.json

  • error TS2322: Type 'readonly (readonly [number, number])[] | number[][]' is not assignable to type 'readonly (readonly [number, number])[]'.

tsconfig.json

  • error TS2322: Type 'readonly (readonly [number, number])[] | number[][]' is not assignable to type 'readonly (readonly [number, number])[]'.

microsoft/vscode

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

build/tsconfig.build.json

extensions/ipynb/tsconfig.json

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

extensions/markdown-language-features/tsconfig.json

extensions/vscode-colorize-tests/tsconfig.json

src/tsconfig.json

src/tsconfig.monaco.json

src/tsconfig.tsec.json

mobxjs/mobx

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

packages/mobx/tsconfig.json

n8n-io/n8n

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

packages/workflow/tsconfig.json

neoclide/coc.nvim

tsconfig.json

  • error TS2322: Type 'T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<infer U> ? U : unknown)[], T> | Extract<...> : never)' is not assignable to type 'T[]'.

palantir/blueprint

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

packages/select/src/tsconfig.json

packages/select/test/tsconfig.json

pubkey/rxdb

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

config/tsconfig.types.json

tsconfig.json

react-hook-form/react-hook-form

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

tsconfig.json

  • error TS2339: Property 'startsWith' does not exist on type 'string | string[]'.
  • error TS2345: Argument of type 'string | string[]' is not assignable to parameter of type 'string'.
  • error TS2345: Argument of type '(Partial<FieldArray<TFieldValues, TFieldArrayName>>[] | (Partial<FieldArray<TFieldValues, TFieldArrayName>> extends any ? Extract<...> | Extract<...> : never) | Extract<...> | (Partial<...> | Partial<...>[])[])[number][]' is not assignable to parameter of type 'Partial<FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>>[]'.
  • error TS2345: Argument of type '(Partial<FieldArray<TFieldValues, TFieldArrayName>>[] | (Partial<FieldArray<TFieldValues, TFieldArrayName>> extends any ? Extract<...> | Extract<...> : never) | Extract<...> | (Partial<...> | Partial<...>[])[])[number][]' is not assignable to parameter of type 'SetStateAction<Partial<unknown>[]>'.
  • error TS2345: Argument of type '(Partial<FieldArray<TFieldValues, TFieldArrayName>>[] | (Partial<FieldArray<TFieldValues, TFieldArrayName>> extends any ? Extract<...> | Extract<...> : never) | Extract<...> | (Partial<...> | Partial<...>[])[])[number][]' is not assignable to parameter of type 'Partial<unknown>[]'.
  • error TS2322: Type '(T | (T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<...> ? U : unknown)[], T> | Extract<...> : never) | Extract<...> | (T | T[])[])[number])[]' is not assignable to type 'T[]'.
  • error TS2322: Type '(T | (T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<...> ? U : unknown)[], T> | Extract<...> : never) | Extract<...> | (T | ... 1 more ... | undefined)[])[number])[]' is not assignable to type '(T | undefined)[]'.
  • error TS2322: Type '((T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<infer U> ? U : unknown)[], T> | Extract<...> : never) | Extract<...> | (T | T[])[])[number] | (T[] | ... 1 more ... | T[][])[number])[]' is not assignable to type 'T[]'.

ReactiveX/rxjs

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

src/tsconfig.cjs.spec.json

  • error TS2322: Type 'T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<infer U> ? U : unknown)[], T> | Extract<...> : never) | (O extends any ? Extract<...> | Extract<...> : never) | Extract<...>' is not assignable to type 'T[]'.
  • error TS2322: Type 'T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<infer U> ? U : unknown)[], T> | Extract<...> : never)' is not assignable to type 'T[]'.

src/tsconfig.esm5.rollup.json

  • error TS2322: Type 'T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<infer U> ? U : unknown)[], T> | Extract<...> : never) | (O extends any ? Extract<...> | Extract<...> : never) | Extract<...>' is not assignable to type 'T[]'.
  • error TS2322: Type 'T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<infer U> ? U : unknown)[], T> | Extract<...> : never)' is not assignable to type 'T[]'.

src/tsconfig.types.json

  • error TS2322: Type 'T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<infer U> ? U : unknown)[], T> | Extract<...> : never) | (O extends any ? Extract<...> | Extract<...> : never) | Extract<...>' is not assignable to type 'T[]'.
  • error TS2322: Type 'T[] | (T extends any ? Extract<(true extends false & T ? any : T extends string | readonly any[] ? unknown : T extends ArrayLike<infer U> | Iterable<infer U> ? U : unknown)[], T> | Extract<...> : never)' is not assignable to type 'T[]'.

statelyai/xstate

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

packages/xstate-inspect/tsconfig.json

  • error TS2322: Type 'TransitionsConfigArray<TContext, TEvent> | (TransitionsConfigMap<TContext, TEvent> extends any ? Extract<...> | Extract<...> : never) | Extract<...>' is not assignable to type '(TransitionConfig<TContext, EventObject> & { event: string; })[]'.

packages/xstate-test/tsconfig.json

  • error TS2322: Type 'TransitionsConfigArray<TContext, TEvent> | (TransitionsConfigMap<TContext, TEvent> extends any ? Extract<...> | Extract<...> : never) | Extract<...>' is not assignable to type '(TransitionConfig<TContext, EventObject> & { event: string; })[]'.

styled-components/styled-components

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

packages/styled-components/tsconfig.json

typeorm/typeorm

tsconfig.json

vercel/hyper

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

tsconfig.json

@graphemecluster
Copy link
Contributor Author

Heck no. It seems that without making it looser it won’t be a solution.

@graphemecluster
Copy link
Contributor Author

I've just tinkered with it a bit. @sandersn Could you please give it another try?

@sandersn
Copy link
Member

@typescript-bot run dt
@typescript-bot test top100
@typescript-bot user test this
@typescript-bot perf test this faster

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 17, 2022

Heya @sandersn, I've started to run the diff-based user code test suite on this PR at dc97890. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 17, 2022

Heya @sandersn, I've started to run the abridged perf test suite on this PR at dc97890. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 17, 2022

Heya @sandersn, I've started to run the diff-based top-repos suite on this PR at dc97890. You can monitor the build here.

Update: The results are in!

@typescript-bot
Copy link
Collaborator

typescript-bot commented Oct 17, 2022

Heya @sandersn, I've started to run the parallelized Definitely Typed test suite on this PR at dc97890. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

@sandersn Here are the results of running the user test suite comparing main and refs/pull/50454/merge:

Something interesting changed - please have a look.

Details

webpack

tsconfig.json

  • [NEW] error TS2322: Type '{ compiler: any; setupResult: any; result: any; state: string; children: any[]; parents: any[]; }[]' is not assignable to type 'Node[]'.

tsconfig.types.json

  • [NEW] error TS7006: Parameter 'stats' implicitly has an 'any' type.
  • [NEW] error TS2322: Type '{ compiler: any; setupResult: undefined; result: undefined; state: "blocked"; children: never[]; parents: never[]; }[]' is not assignable to type 'Node[]'.
  • [NEW] error TS7053: Element implicitly has an 'any' type because expression of type 'number' can't be used to index type '(T[P] & null extends any ? (T[P] & null extends string | readonly any[] ? never : T[P] & null extends ArrayLike<infer U> | Iterable<infer U> ? Extract<...> : never) | ({} extends Required<...> ? never : Extract<...>) : never) | (T[P] & {} extends any ? (true extends false & T[P] ? Extract<...> : T[P] & {} extends st...'.
  • [MISSING] error TS2322: Type '{ compiler: Compiler; setupResult: undefined; result: undefined; state: "blocked"; children: never[]; parents: never[]; }[]' is not assignable to type 'Node[]'.

@typescript-bot
Copy link
Collaborator

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

Here they are:

Comparison Report - main..50454

Metric main 50454 Delta Best Worst
Angular - node (v16.17.1, x64)
Memory used 352,473k (± 0.02%) 353,198k (± 0.01%) +726k (+ 0.21%) 353,151k 353,247k
Parse Time 1.90s (± 0.66%) 1.91s (± 1.03%) +0.01s (+ 0.58%) 1.87s 1.95s
Bind Time 0.75s (± 0.91%) 0.75s (± 0.66%) -0.00s (- 0.00%) 0.74s 0.76s
Check Time 5.71s (± 0.60%) 5.71s (± 0.61%) -0.00s (- 0.02%) 5.64s 5.77s
Emit Time 6.16s (± 0.94%) 6.13s (± 0.61%) -0.04s (- 0.57%) 6.06s 6.23s
Total Time 14.51s (± 0.48%) 14.49s (± 0.44%) -0.03s (- 0.19%) 14.37s 14.70s
Compiler-Unions - node (v16.17.1, x64)
Memory used 197,773k (± 0.38%) 198,113k (± 0.50%) +340k (+ 0.17%) 197,406k 200,787k
Parse Time 0.79s (± 0.76%) 0.79s (± 0.74%) +0.00s (+ 0.25%) 0.78s 0.80s
Bind Time 0.46s (± 1.04%) 0.46s (± 0.82%) -0.00s (- 0.44%) 0.45s 0.46s
Check Time 6.48s (± 0.59%) 6.47s (± 0.48%) -0.01s (- 0.17%) 6.41s 6.56s
Emit Time 2.28s (± 0.90%) 2.31s (± 1.32%) +0.03s (+ 1.40%) 2.28s 2.42s
Total Time 10.01s (± 0.53%) 10.03s (± 0.42%) +0.02s (+ 0.20%) 9.92s 10.11s
Monaco - node (v16.17.1, x64)
Memory used 331,123k (± 0.01%) 331,137k (± 0.01%) +13k (+ 0.00%) 331,078k 331,212k
Parse Time 1.44s (± 0.84%) 1.44s (± 0.74%) +0.00s (+ 0.07%) 1.41s 1.46s
Bind Time 0.70s (± 0.86%) 0.69s (± 0.71%) -0.00s (- 0.14%) 0.69s 0.71s
Check Time 5.47s (± 0.86%) 5.47s (± 0.44%) -0.01s (- 0.13%) 5.42s 5.54s
Emit Time 3.25s (± 0.60%) 3.25s (± 0.45%) +0.01s (+ 0.28%) 3.21s 3.29s
Total Time 10.85s (± 0.64%) 10.85s (± 0.26%) -0.00s (- 0.00%) 10.78s 10.91s
TFS - node (v16.17.1, x64)
Memory used 294,076k (± 0.02%) 294,022k (± 0.02%) -54k (- 0.02%) 293,860k 294,120k
Parse Time 1.23s (± 2.00%) 1.23s (± 1.27%) -0.00s (- 0.24%) 1.18s 1.26s
Bind Time 0.64s (± 0.35%) 0.65s (± 0.73%) +0.01s (+ 0.94%) 0.64s 0.66s
Check Time 5.13s (± 0.58%) 5.12s (± 0.40%) -0.01s (- 0.20%) 5.09s 5.18s
Emit Time 3.49s (± 0.85%) 3.48s (± 0.58%) -0.01s (- 0.17%) 3.44s 3.53s
Total Time 10.48s (± 0.48%) 10.47s (± 0.41%) -0.01s (- 0.10%) 10.40s 10.56s
material-ui - node (v16.17.1, x64)
Memory used 438,355k (± 0.01%) 438,383k (± 0.01%) +28k (+ 0.01%) 438,327k 438,436k
Parse Time 1.73s (± 1.38%) 1.75s (± 1.37%) +0.01s (+ 0.75%) 1.69s 1.79s
Bind Time 0.54s (± 0.55%) 0.55s (± 0.87%) +0.00s (+ 0.92%) 0.54s 0.56s
Check Time 12.54s (± 1.09%) 12.52s (± 0.33%) -0.02s (- 0.15%) 12.39s 12.61s
Emit Time 0.00s (± 0.00%) 0.00s (± 0.00%) 0.00s ( NaN%) 0.00s 0.00s
Total Time 14.82s (± 1.07%) 14.81s (± 0.30%) -0.00s (- 0.01%) 14.69s 14.94s
xstate - node (v16.17.1, x64)
Memory used 554,419k (± 0.02%) 555,329k (± 0.01%) +911k (+ 0.16%) 555,151k 555,547k
Parse Time 2.31s (± 0.49%) 2.32s (± 0.28%) +0.01s (+ 0.39%) 2.30s 2.33s
Bind Time 0.90s (± 2.16%) 0.90s (± 2.41%) -0.00s (- 0.22%) 0.87s 0.96s
Check Time 1.42s (± 0.86%) 1.47s (± 1.06%) +0.05s (+ 3.38%) 1.42s 1.50s
Emit Time 0.07s (± 0.00%) 0.07s (± 0.00%) 0.00s ( 0.00%) 0.07s 0.07s
Total Time 4.70s (± 0.31%) 4.75s (± 0.36%) +0.05s (+ 1.11%) 4.71s 4.79s
System
Machine Namets-ci-ubuntu
Platformlinux 5.4.0-126-generic
Architecturex64
Available Memory16 GB
Available Memory15 GB
CPUs4 × Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Hosts
  • node (v16.17.1, x64)
Scenarios
  • Angular - node (v16.17.1, x64)
  • Compiler-Unions - node (v16.17.1, x64)
  • Monaco - node (v16.17.1, x64)
  • TFS - node (v16.17.1, x64)
  • material-ui - node (v16.17.1, x64)
  • xstate - node (v16.17.1, x64)
Benchmark Name Iterations
Current 50454 10
Baseline main 10

Developer Information:

Download Benchmark

@typescript-bot
Copy link
Collaborator

@sandersn Here are the results of running the top-repos suite comparing main and refs/pull/50454/merge:

Something interesting changed - please have a look.

Details

cheeriojs/cheerio

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

tsconfig.json

  • error TS2322: Type 'ChildNode[] | (S extends any ? (true extends false & S ? Extract<any[], S> : S extends string | readonly any[] ? never : S extends ArrayLike<...> | Iterable<...> ? Extract<...> : never) | (true extends false & S ? never : {} extends Required<...> ? S & any[] : Extract<...>) : never) | T[] | (NonNullable<...> extends...' is not assignable to type 'AnyNode[] | undefined'.

conwnet/github1s

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

extensions/github1s/tsconfig.json

  • error TS2322: Type 'T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never)' is not assignable to type 'T[]'.

excalidraw/excalidraw

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

tsconfig-types.json

  • error TS2322: Type 'readonly (readonly [number, number])[] | number[][]' is not assignable to type 'readonly (readonly [number, number])[]'.

tsconfig.json

  • error TS2322: Type 'readonly (readonly [number, number])[] | number[][]' is not assignable to type 'readonly (readonly [number, number])[]'.

microsoft/vscode

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

src/tsconfig.monaco.json

  • error TS2345: Argument of type '(_: T) => U' is not assignable to parameter of type '((value: any, index: number, array: any[]) => U) & ((value: unknown, index: number, array: unknown[]) => U) & ((value: any, index: number, array: readonly any[]) => U) & ((value: T, index: number, array: T[]) => U)'.
  • error TS2322: Type 'T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never)' is not assignable to type 'T[]'.

src/tsconfig.tsec.json

n8n-io/n8n

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

packages/workflow/tsconfig.json

neoclide/coc.nvim

tsconfig.json

  • error TS2322: Type 'T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never)' is not assignable to type 'T[]'.

react-hook-form/react-hook-form

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

tsconfig.json

  • error TS2339: Property 'startsWith' does not exist on type 'string | string[]'.
  • error TS2345: Argument of type 'string | string[]' is not assignable to parameter of type 'string'.
  • error TS2345: Argument of type '(Partial<FieldArray<TFieldValues, TFieldArrayName>>[] | (Partial<FieldArray<TFieldValues, TFieldArrayName>> extends any ? (true extends false & Partial<...> ? Extract<...> : Partial<...> extends string | readonly any[] ? never : Partial<...> extends ArrayLike<...> | Iterable<...> ? Extract<...> : never) | (true exte...' is not assignable to parameter of type 'Partial<FieldArrayWithId<TFieldValues, TFieldArrayName, TKeyName>>[]'.
  • error TS2345: Argument of type '(Partial<FieldArray<TFieldValues, TFieldArrayName>>[] | (Partial<FieldArray<TFieldValues, TFieldArrayName>> extends any ? (true extends false & Partial<...> ? Extract<...> : Partial<...> extends string | readonly any[] ? never : Partial<...> extends ArrayLike<...> | Iterable<...> ? Extract<...> : never) | (true exte...' is not assignable to parameter of type 'SetStateAction<Partial<unknown>[]>'.
  • error TS2345: Argument of type '(Partial<FieldArray<TFieldValues, TFieldArrayName>>[] | (Partial<FieldArray<TFieldValues, TFieldArrayName>> extends any ? (true extends false & Partial<...> ? Extract<...> : Partial<...> extends string | readonly any[] ? never : Partial<...> extends ArrayLike<...> | Iterable<...> ? Extract<...> : never) | (true exte...' is not assignable to parameter of type 'Partial<unknown>[]'.
  • error TS2322: Type '(T | (T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never) | (T | T[])[])[number])[]' is not assignable to type 'T[]'.
  • error TS2322: Type '(T | (T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never) | (T | ... 1 more ... | undefin...' is not assignable to type '(T | undefined)[]'.
  • error TS2322: Type '(T | T[] | (T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<...> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never) | (T | T[])[])[number])[]' is not assignable to type 'T[]'.

ReactiveX/rxjs

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

src/tsconfig.cjs.spec.json

  • error TS2322: Type 'T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never) | (O extends any ? (true extends fals...' is not assignable to type 'T[]'.
  • error TS2322: Type 'T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never)' is not assignable to type 'T[]'.

src/tsconfig.esm5.rollup.json

  • error TS2322: Type 'T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never) | (O extends any ? (true extends fals...' is not assignable to type 'T[]'.
  • error TS2322: Type 'T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never)' is not assignable to type 'T[]'.

src/tsconfig.types.json

  • error TS2322: Type 'T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never) | (O extends any ? (true extends fals...' is not assignable to type 'T[]'.
  • error TS2322: Type 'T[] | (T extends any ? (true extends false & T ? Extract<any[], T> : T extends string | readonly any[] ? never : T extends ArrayLike<infer U> | Iterable<...> ? Extract<...> : never) | (true extends false & T ? never : {} extends Required<...> ? T & any[] : Extract<...>) : never)' is not assignable to type 'T[]'.

refined-github/refined-github

tsconfig.json

  • error TS2322: Type 'Item[] | (Item extends any ? (true extends false & Item ? Extract<any[], Item> : Item extends string | readonly any[] ? never : Item extends ArrayLike<...> | Iterable<...> ? Extract<...> : never) | (true extends false & Item ? never : {} extends Required<...> ? Item & any[] : Extract<...>) : never)' is not assignable to type 'Item[]'.

statelyai/xstate

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

packages/xstate-inspect/tsconfig.json

  • error TS2322: Type 'TransitionsConfigArray<TContext, TEvent> | (TransitionsConfigMap<TContext, TEvent> extends any ? (true extends false & TransitionsConfigMap<...> ? Extract<...> : TransitionsConfigMap<...> extends string | readonly any[] ? never : TransitionsConfigMap<...> extends ArrayLike<...> | Iterable<...> ? Extract<...> : never...' is not assignable to type '(TransitionConfig<TContext, EventObject> & { event: string; })[]'.

packages/xstate-test/tsconfig.json

  • error TS2322: Type 'TransitionsConfigArray<TContext, TEvent> | (TransitionsConfigMap<TContext, TEvent> extends any ? (true extends false & TransitionsConfigMap<...> ? Extract<...> : TransitionsConfigMap<...> extends string | readonly any[] ? never : TransitionsConfigMap<...> extends ArrayLike<...> | Iterable<...> ? Extract<...> : never...' is not assignable to type '(TransitionConfig<TContext, EventObject> & { event: string; })[]'.

typeorm/typeorm

tsconfig.json

  • error TS2322: Type '_QueryDeepPartialEntity<ObjectLiteral extends Entity ? unknown : Entity>[] | (_QueryDeepPartialEntity<ObjectLiteral extends Entity ? unknown : Entity> extends any ? (true extends false & _QueryDeepPartialEntity<...> ? Extract<...> : _QueryDeepPartialEntity<...> extends string | readonly any[] ? never : _QueryDeepPar...' is not assignable to type '_QueryDeepPartialEntity<ObjectLiteral extends Entity ? unknown : Entity>[]'.
  • error TS2345: Argument of type '_QueryDeepPartialEntity<ObjectLiteral extends Entity ? unknown : Entity>[] | (_QueryDeepPartialEntity<ObjectLiteral extends Entity ? unknown : Entity> extends any ? (true extends false & _QueryDeepPartialEntity<...> ? Extract<...> : _QueryDeepPartialEntity<...> extends string | readonly any[] ? never : _QueryDeepPar...' is not assignable to parameter of type 'ObjectLiteral[]'.
  • error TS7053: Element implicitly has an 'any' type because expression of type 'string | number | symbol' can't be used to index type 'string | number | symbol'.
  • error TS2339: Property 'indexOf' does not exist on type 'never'.

wenyan-lang/wenyan

tsconfig.json

@graphemecluster
Copy link
Contributor Author

Actually most of the cases above just work by adding an extends any constraint on the generic parameter (see the test cases I added). Perhaps it’s a separated but related problem. @sandersn, or perhaps @RyanCavanaugh, sorry to bother you again, but could you please inspect this?

@sandersn
Copy link
Member

@graphemecluster can you explain what the failures are like that would have been fixed by adding extends any? 4.8 did make unconstrained type parameters implicitly extend unknown instead of {}, and a common workaround was to add an explicit extends any. Maybe that's related.

Could you also add a detailed explanation of the new type of isArray? I read the type and couldn't understand the reason for almost any of its intricacies.

@graphemecluster
Copy link
Contributor Author

@sandersn
A rough explanation looks like:

type ToArray<T> =
    // Distribute it
    T extends any ?
        (
            // if T == any, return any[]
            true extends false & T ? Extract<any[], T> : 
            // if T is an array-like or iterable object but not string or array, return U[]
            T extends string | readonly any[] ? never :
            T extends ArrayLike<infer U> | Iterable<infer U> ? Extract<U[], T> :
            // fallback to the bottom cases
            never
        ) | (
            // T == any has been covered above, so skip it
            true extends false & T ? never : 
            // if T is any Record-like object (object with only index signature),
            // intersect it with any array (this case should be rare, but a use
            // case was found in test suite and being added to the test case file)
            {} extends Required<T> ? T & any[] :
            // otherwise, for cases not being covered by the above, extract all
            // the arrays and readonly arrays out and dispose the remaining
            Extract<T, readonly any[]>
        )
    : never;

There are no special reasons to separate the cases into two, but without this TypeScript may not think the result type is an array and fires error on test cases fc and fe (also see the earlier test suite result).
The use of Extract is to make sure that the predicate is assignable to the parameter type. (Using intersection instead, the result would be awful.)

Actually using extends unknown instead of extends any in test cases ff and fg does not affect the result at all, but it's not the case when the constraint is removed. That means there must be some problems with generic parameters without constraint in TypeScript.

@graphemecluster
Copy link
Contributor Author

I just noticed that replacing Extract<T, readonly any[]> with T extends readonly any[] ? T : never will make test cases fc and fe fail. I can hardly understand why.

@sandersn
Copy link
Member

My feeling is that this problem is too complex to have a fix that I'm comfortable shipping in the standard lib. At least one that doesn't break existing code.

If you can show that there aren't going to be many breaks across the ecosystem of packages, and that compilation won't slow down, it would still be worthwhile. But I think that's too much effort for this.

@graphemecluster
Copy link
Contributor Author

@sandersn If possible, might you try running the test suite in 4.7.4 before #51242 is solved?

@sandersn
Copy link
Member

I talked with Ryan about this again, and we don't think there's any way that a conditional return type will work. Specifically, it won't be usable in higher-order, generic uses. But it's complex enough that there are likely other corner-case failures I haven't thought of. I think this PR should be closed.

However, we want to work on the other lib fix PRs and bring them to the Typescript design meeting after finding out how well they work on existing code. I'll start with the smallest one and start user tests, etc.

@sandersn sandersn moved this from Waiting on reviewers to Waiting on author in PR Backlog Apr 11, 2023
@graphemecluster
Copy link
Contributor Author

Thanks for picking this up. Now that I agree eventually all solutions tinkering with the lib won’t be perfect, I am going to root around in the compiler for a better way out. Let’s close this PR until then.

PR Backlog automation moved this from Waiting on author to Done Apr 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug For Milestone Bug PRs that fix a bug with a specific milestone
Projects
PR Backlog
  
Done
3 participants