Repository: TypeScript
Issue: Type argument inference fails using partial generic type when it should be possible
Labels: Possible Improvement

# Bug Report

<!--
  Please fill in each section completely. Thank you!
-->

When trying to infer a type argument when the argument is used as a generic to another type which itself is nested inside `Partial<...>`, type inference fails.

### 🔎 Search Terms

<!--
  What search terms did you use when trying to find an existing bug report?
  List them here so people in the future can find this one more easily.
-->

type inference fail partial generic
type inference error partial generic

### 🕗 Version & Regression Information

<!-- When did you start seeing this bug occur?

"Bugs" that have existed in TS for a long time are very likely to be FAQs; refer to
  https://github.com/Microsoft/TypeScript/wiki/FAQ#common-bugs-that-arent-bugs

If possible, please try testing the nightly version of TS to see if it's already been fixed.
For npm: `typescript@next`
This is also the 'Nightly' version in the playground: http://www.typescriptlang.org/play/?ts=Nightly

Note: The TypeScript Playground can be used to try older versions of TypeScript.

Please keep and fill in the line that best applies:
-->
This is the behavior in every version I tried, and I reviewed the FAQ for entries about inference.

### ⏯ Playground Link

<!--
  A link to a TypeScript Playground "Share" link which shows this behavior.
  This should have the same code as the code snippet below, and use whichever settings are relevant to your report.

  As a last resort, you can link to a repo, but these will be slower for us to investigate.
-->
[Playground link with relevant code](https://www.typescriptlang.org/play?#code/C4TwDgpgBAKghgJwOYWFAvFA5AWwPYB2SeAJgEZZQA+2AVgM6EDKAxgBYQ5wDslNWeSAQCCYAJYBmLAChpYgsAgIAZnBbQAcngRcANgAUEg+gB4Y8ZKigQAHooIl6sRCmAA+KAG9pUKMBeoAFywFq4+UATaesEEAK44ZErSAL6y8ooqatAAsoTEhsZe4f6WwMEAonYIasBmAcAANNj4RKQUbuEtxDHxiQgpsqCQUAVgpub11nYQDk6hVphYDMzsnDxYHpgTpVP2jlCVLLqxJBB1pU24eW0b4QD8UFo6cAZGY2bz7uHBua2j9ABuWQsQj0NBoTAfSa2PZzSaLZYEVgcLi8NwACjAb3owX0iGAYheJn+UNKbjcAEoMB5PKlpMB0Z4-PVggIhKJJJRkhSgA)

### 💻 Code

<!-- Please post the relevant code sample here as well. This code and the Playground code should be the same, do not use separate examples -->
```ts
type Target = 'mongodb' | 'jsonSchema7' | 'openApi3'

interface NormalProps<TTarget extends Target> {
  target: TTarget
  normal: number
}

interface MongoProps {
  target: Extract<Target, 'mongodb'>
  mongo: number
}

type Props<TTarget extends Target = 'jsonSchema7'> = TTarget extends Exclude<Target, 'mongodb'>
  ? NormalProps<TTarget>
  : MongoProps;

const t = <TTarget extends Target = 'jsonSchema7'>(props: Partial<Props<TTarget>>) => {}

t({ target: 'openApi3' })
```

### 🙁 Actual behavior

<!-- What happened, and why it was wrong -->

Type inference fails, error is displayed: `Type '"openApi3"' is not assignable to type '"jsonSchema7"'.`. When manually passing the generic - `t<'openApi3'>({ target: 'openApi3' })` - everything works fine.

### 🙂 Expected behavior

<!-- What you expected to happen instead, and why -->

Type inference should be successful, as one of the discriminating properties (`target`) is set.