microsoft / microsoft/TypeScript

Parameters typed as `unknown` even when the function type has the correct types

Open
#57,654 6 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

🔎 Search Terms

mapped types, function types

🕗 Version & Regression Information
  • This is the behavior that starts in version 4.9, and I reviewed the FAQ for entries about function types
    All the versions prior to 4.9 have both scenarios with the params typed to unknown
⏯ Playground Link

Playground Link

💻 Code

No response

🙁 Actual behavior

The function with no default shows the proper function type but the parameters are typed as unknown

🙂 Expected behavior

The parameters should have the types of the function params

Additional information about the issue

There is also a smaller reproduction that was made by mkantor on discord.

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 with the two linked TypeScript Playground reproductions and compare the parameter inference behavior across the reported versions. Trace the mapped-type and function-type inference involved, then confirm that parameters receive the function's declared types rather than unknown in both scenarios.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.