microsoft / microsoft/TypeScript

Invalid type inference when using arrow function but normal functions is ok

Open
#55,017 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs More Info
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms

Invalid type inference with arrow function

🕗 Version & Regression Information
  • This changed between versions @effect/io^0.30 and @effect/io>=0.31. The main change that I suspect is causing the bug is this commit.
⏯ Playground Link

At least, playground cannot import third-party lib(effect). so here, I provide some stackblitz links:

💻 Code

🙁 Actual behavior

If you write it as a regular function expression, the type is inferred without any problems. but writing in arrow function expressions causes problems with type inference.

🙂 Expected behavior

In the same way that the Effect library works, the resolve function should be correctly typed by inferring the dependencies passed through the effect object, the type of the required objects, and the way the function is written. There should be no difference in the way the resolve function is written.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the three StackBlitz reproductions and inspect the suspected @effect/io commit linked in the report, focusing on the change affecting inference. Confirm the behavior for equivalent regular-function and arrow-function forms; done means the arrow form infers resolve from the effect dependencies and required object types in the same way.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.