[Typescript] 105. Medium - Placeholder

type Placeholder<T extends string> = T extends `${string}{${infer P}}${infer REST}`
  ? P | Placeholder<REST>
  : never;

declare function format<S extends string>(template: S, args: Record<Placeholder<S>, unknown>): string

let text = format('Name: {name}, Age: {age}', {name: 'Homer', age: 42})

posted @   Zhentiw  阅读(10)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2019-11-16 [Flutter] Style a message chat style-ish bubble
2019-11-16 [Flutter] Flexible the Widget height to available space
2019-11-16 [Flutter] Clear a TextField after send button
2019-11-16 [Flutter] Using StreamBuilder to build a List of Text Widget based on the data from Firebase
2016-11-16 [MobX] MobX fundamentals: deriving computed values and managing side effects with reactions
2014-11-16 [Grunt] External Config
2014-11-16 [Grunt] Uglify
点击右上角即可分享
微信分享提示