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

Incorrect automatically type infer #57921

Closed
hanakannzashi opened this issue Mar 24, 2024 · 2 comments
Closed

Incorrect automatically type infer #57921

hanakannzashi opened this issue Mar 24, 2024 · 2 comments
Labels
Duplicate An existing issue was already created

Comments

@hanakannzashi
Copy link

πŸ”Ž Search Terms

automatically infer

πŸ•— Version & Regression Information

  • This is NOT a crash

⏯ Playground Link

No response

πŸ’» Code

There is no issue

function test<T>(t1: T, t2: T): never {
  throw Error('todo');
}

function custom<T>(f: (data: T) => T): T {
  throw Error('todo');
}

async function main() {
  test(10, custom((data) => {
    throw Error('todo')
  }))
}
no-issue

Function custom correctly inffered

There is issue

function test<T>(options: {
  t1: T,
  t2: T
}): never {
  throw Error('todo');
}

function custom<T>(f: (data: T) => T): T {
  throw Error('todo');
}

async function main() {
  test({
    t1: 10,
    t2: custom((data) => {
      throw Error('todo')
    })
  })
}
issue

Function custom incorrectly inffered, the T should be number instead of unknown

πŸ™ Actual behavior

Function custom incorrectly infered, the T infered as unknown

πŸ™‚ Expected behavior

Function custom correctly infered, the T infered as number

Additional information about the issue

No response

@RyanCavanaugh
Copy link
Member

#47599

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label Mar 25, 2024
@typescript-bot
Copy link
Collaborator

This issue has been marked as "Duplicate" and has seen no recent activity. It has been automatically closed for house-keeping purposes.

@typescript-bot typescript-bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants