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

can't infer an empty object in function with ThisType #52037

Open
rudyxu1102 opened this issue Dec 28, 2022 · 0 comments
Open

can't infer an empty object in function with ThisType #52037

rudyxu1102 opened this issue Dec 28, 2022 · 0 comments
Labels
Needs Investigation This issue needs a team member to investigate its status.
Milestone

Comments

@rudyxu1102
Copy link

rudyxu1102 commented Dec 28, 2022

Bug Report

It can't inferred right when I try to infer an empty object in function with ThisType

🔎 Search Terms

infer empty object

🕗 Version & Regression Information

  • This is a crash
  • This changed between versions 3.5.1 and 3.6.2
  • 3.5.1 is work

⏯ Playground Link

Playground link with relevant code

💻 Code

type ComponentPropsOptions = {} | string[];

export function foo<propsOptions extends ComponentPropsOptions>(options: {
  props: propsOptions & ThisType<void>;
}): propsOptions;

export function foo(options: any) {
  return options;
}

const fail = foo({
  props: {},
});

// {} | string[]
type FailType = typeof fail // can't infer to {}

const work = foo({
  props: {
    test: '1'
  },
});

// { test: string;}
type WorkType = typeof work // it‘s work

🙁 Actual behavior

type FailType = {} | string[]

🙂 Expected behavior

type FailType = {} 
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jan 5, 2023
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Investigation This issue needs a team member to investigate its status.
Projects
None yet
Development

No branches or pull requests

2 participants