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

4.8 regression assigning object literal to intersection of conditional type and object type #50619

Closed
andrewbranch opened this issue Sep 2, 2022 · 0 comments · Fixed by #50620
Labels
Fix Available A PR has been opened for this issue

Comments

@andrewbranch
Copy link
Member

There's a Stack Overflow question that seems to be related to this PR:

interface Baz {
  foo: { a: number };
}

const createDefaultExample = <K extends keyof Baz>(x: K): Baz[K] & { x: K; } => {
  return { a: 0, x }; // okay in TS4.7, error in TS4.8
}

Playground link

Looks like the fix for #49520 might have broken this. Is it a bug and should this be filed as such? Or is it intended in some way?


EDIT: Looks like the above was fixed by #50261 but this one persists:

type Foo<K> = K extends unknown ? { a: number } : unknown
const createDefaultExample = <K,>(x: K): Foo<K> & { x: K; } => {
  return { a: 1, x: x }; // okay in TS 4.7.4, error in TS 4.8.2
}

Playground link to code

Same question, I guess... bug? Not bug? New issue?

Originally posted by @jcalz in #49503 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants