首页
注册
登录
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请
登录
V2EX 提问指南
广告
V2EX
›
问与答
ts interface 如何定义一个函数类型 key,其入参类型和返回值类型为实际传入函数对应类型
youngluo
·
2023-06-05 17:25:54 +08:00
· 582 次点击
这是一个创建于 505 天前的主题,其中的信息可能已经有所发展或是发生改变。
类型
函数
返回值
interface
2 条回复
•
2023-06-05 22:55:58 +08:00
1
MozzieW
2023-06-05 17:47:48 +08:00
也不是说描述不清楚,但是建议加上用例、场景。
听起来像是:泛型?
2
Danswerme
2023-06-05 22:55:58 +08:00
这样?
interface SomeFn<T, R> {
(params: T): R
}
const fn: SomeFn<string, number> = (a) => Number(a);
关于
·
帮助文档
·
博客
·
API
·
FAQ
·
实用小工具
·
2853 人在线
最高记录 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 26ms ·
UTC 14:48
·
PVG 22:48
·
LAX 07:48
·
JFK 10:48
Developed with
CodeLauncher
♥ Do have faith in what you're doing.