Microsoft/TypeScript

No constituent of type 'Function | (T & Function)' is callable.

Open

#46,066 建立於 2021年9月26日

在 GitHub 查看
 (6 留言) (0 反應) (0 負責人)TypeScript (6,726 fork)batch import
BugDomain: Error MessagesEffort: DifficultHelp Wanted

倉庫指標

Star
 (48,455 star)
PR 合併指標
 (平均合併 6天 17小時) (30 天內合併 9 個 PR)

描述

Bug Report

🔎 Search Terms

generic function union-type call-signatures

🕗 Version & Regression Information

  • This is a crash
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about Generics
  • I was unable to test this on prior versions because _______

⏯ Playground Link

Playground link with relevant code

💻 Code

type Test = <T>(fn: T | Function) => void;
const test: Test = (fn) => {
  return typeof fn === 'function' ? fn() : null;
};
// This expression is not callable.
// No constituent of type 'Function | (T & Function)' is callable.

🙁 Actual behavior

Compiler throw error: This expression is not callable. Not all constituents of type 'Function | (T & Function)' are callable.

🙂 Expected behavior

Compile success

because both 'Function | (T & Function)' are callable.

貢獻者指南