-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Infer on tuples broken on nightly #42331
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
Comments
I can reproduce it, last working build was 4.2.0-dev.20210112. |
It seems related to tuples, rewriting as: type _R<T> = {t: T} extends {t: { _R: (_: infer R) => void }} ? R : never
type _E<T> = {t: T} extends {t: { _E: () => infer E }} ? E : never
type _A<T> = {t: T} extends {t: { _A: () => infer A }} ? A : never
interface Sync<R, E, A> {
_R: (_: R) => void
_E: () => E
_A: () => A
}
type R = _R<Sync<number, string, void>>
type E = _E<Sync<number, string, void>>
type A = _A<Sync<number, string, void>> Works on nightly too |
Well seems definitely related to tuples: type X = [0] extends [infer A] ? A : never
|
@weswigham Might this be caused by #42248? |
Hm, must be? I'll have to see why it caused this, since unwrapping the tuples for the "is generic" checks doesn't seem like it should affect inference of |
Is this related or unrelated? type Hmm = [never] extends [infer T, ...any[]] ?
[T, [never] extends [T] ? true : false]
: never
// TS 4.1.5
// type Hmm = [never, true] ✔
// TS 4.2.2
// type Hmm = [never, false] ❌
// So T is inferred as never, but [never] extends [T] is false? |
Bug Report
The latest nightly release breaks non distributive
infer
🕗 Version & Regression Information
Bug introduced in the latest nighty release
💻 Code
🙁 Actual behavior
https://www.typescriptlang.org/play?ts=4.2.0-dev.20210114#code/C4TwDgpgBA+gSgHgCoD4oF4oG0kF0oQAewEAdgCYDO2A3rHAFxQAUMTAlqQGYQBOUcAJQY0ANwD27clAC++APwCoTUhFF8AUKEiwAosjSYc+IiQrUsdGLqbNh6NJx79dshVFcq1m7dBgBBAwxsPAJiMipaWH9be0duPih-NyhFZK91Xg0NThJeLgBDAGNoAGUQUiKEOAAaDzr-NBoNKHpbNgE4qAkpFr1YkQ8+gIGHJI0ZbN8lTHgEcsqEUgBXAFsAIz46ymBeTgBzOp7yFBQtcGhXWf0FqpWNragdvdJD7skTs+nk2cDbpbWm14212ByOH1OGiAA
🙂 Expected behavior
https://www.typescriptlang.org/play?ts=4.2.0-beta#code/C4TwDgpgBA+gSgHgCoD4oF4oG0kF0oQAewEAdgCYDO2A3rHAFxQAUMTAlqQGYQBOUcAJQY0ANwD27clAC++APwCoTUhFF8AUKEiwAosjSYc+IiQrUsdGLqbNh6NJx79dshVFcq1m7dBgBBAwxsPAJiMipaWH9be0duPih-NyhFZK91Xg0NThJeLgBDAGNoAGUQUiKEOAAaDzr-NBoNKHpbNgE4qAkpFr1YkQ8+gIGHJI0ZbN8lTHgEcsqEUgBXAFsAIz46ymBeTgBzOp7yFBQtcGhXWf0FqpWNragdvdJD7skTs+nk2cDbpbWm14212ByOH1OGiAA
The text was updated successfully, but these errors were encountered: