1 Star 0 Fork 0

Sunny / type-challenges

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.zh-CN.md 1.95 KB
一键复制 编辑 原始数据 按行查看 历史
Keit Oliveira 提交于 2024-02-07 07:59 . i18n: translate to pt-br (#31698)

获取函数返回类型 中等 #infer #built-in

by Anthony Fu @antfu

接受挑战    English 日本語 한국어 Português (BR)

不使用 ReturnType 实现 TypeScript 的 ReturnType<T> 泛型。

例如:

const fn = (v: boolean) => {
  if (v)
    return 1
  else
    return 2
}

type a = MyReturnType<typeof fn> // 应推导出 "1 | 2"

返回首页 分享你的解答 查看解答
1
https://gitee.com/ztes/type-challenges.git
git@gitee.com:ztes/type-challenges.git
ztes
type-challenges
type-challenges
main

搜索帮助