-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Description
Bug Report
🔎 Search Terms
Generics, Union, Narrow, Narrowing, Distributed, Conditional, Inference
🕗 Version & Regression Information
TS v4.3.5 (and nightly build as of 7/23/2021)
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about conditional types & inference
⏯ Playground Link
Playground link with relevant code
💻 Code
type Tuplify<A> = A extends unknown ? [A] : never
type test = Tuplify<'a' | 'b'> // test = ['a'] | ['b']
declare const inferFunc: <A, R extends Tuplify<A>>(a: A, b: R) => R
declare const testval: 'a' | 'b'
const retval: ['a'] = inferFunc(testval, ['a']) // this should work (?)🙁 Actual behavior
const retval: ['a'] | ['b']🙂 Expected behavior
const retval: ['a']I expected R to be inferred as a subtype of Tuplify<A>, since that's how parameterized union types work as of #13995 (I think)
Please forgive me if this is actually expected behavior or has already been reported
p-szmwhzx5byb
Metadata
Metadata
Assignees
Labels
No labels