Skip to content

Explain how the ultimate TS type development experience is achieved in frameworks: tRPC, Prisma, Hono, Elysia...

License

Notifications You must be signed in to change notification settings

linbudu599/framework-typings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

框架中的类型编程

许多前端框架为了带给开发者极致的开发体验,已经卷得一去不回头,尤其是在类型推导上,它们已经把泛型、模板字符串类型、条件类型等等玩出了花。比如,Prisma 能根据 select 的属性来推导返回值的类型,Hono 能从路由地址解析出参数,Elysia 能把路由地址转化成链式调用...

这些神奇的功能都是如何实现的?这个仓库收录了这些框架简化后的类型编程实现,帮助你从实践出发,理解如何实现这些酷炫的类型推导。

import { request } from './Hono';

request('/user/:name/:id', (ctx) => {
  const name = ctx.param('name');
  const id = ctx.param('id');
});
import { findUnique } from './Prisma';

const result1 = findUnique({
  where: { id: 1 },
  select: { id: true, email: true },
});

result1?.id;
result1?.email;
result1?.name; // x

文章列表一览:

About

Explain how the ultimate TS type development experience is achieved in frameworks: tRPC, Prisma, Hono, Elysia...

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published