File tree Expand file tree Collapse file tree 6 files changed +53
-8
lines changed
Expand file tree Collapse file tree 6 files changed +53
-8
lines changed Original file line number Diff line number Diff line change 1+ import { bench } from '@ark/attest'
2+ import { type DeepPartial } from '../src/base.ts'
3+
4+ export type BaseLine = DeepPartial < { } >
5+
6+ bench ( 'prettify' , ( ) => {
7+ type User = DeepPartial < {
8+ id : number
9+ scores : number [ ]
10+ profile : {
11+ twitterHandle ?: string
12+ githubHandle ?: string
13+ }
14+ } >
15+
16+ return { } as User
17+ } ) . types ( [ 1 , 'instantiations' ] )
Original file line number Diff line number Diff line change 1+ import { bench } from '@ark/attest'
2+ import { type Prettify } from '../src/base.ts'
3+
4+ export type BaseLine = Prettify < { } >
5+
6+ bench ( 'prettify' , ( ) => {
7+ type JSONObject < V > = Prettify < {
8+ [ K in keyof V ] : V [ K ]
9+ } >
10+ type JSONArray < V > = Prettify < Array < V > >
11+
12+ type User = JSONObject < {
13+ id : number
14+ scores : JSONArray < number >
15+ profile : JSONObject < {
16+ twitterHandle ?: string
17+ githubHandle ?: string
18+ } >
19+ } >
20+
21+ return { } as User
22+ } ) . types ( [ 1 , 'instantiations' ] )
Original file line number Diff line number Diff line change 1+ import { bench } from '@ark/attest'
2+ import { type InferRouteParams } from '../src/route.ts'
3+
4+ export type BaseLine = InferRouteParams < '/' >
5+
6+ bench ( 'prettify' , ( ) => {
7+ type ViewUser = InferRouteParams < '/users/:id/:name/:slug?' >
8+ return { } as ViewUser
9+ } ) . types ( [ 1 , 'instantiations' ] )
Original file line number Diff line number Diff line change 3030 "@adonisjs/eslint-config" : " ^3.0.0-next.1" ,
3131 "@adonisjs/prettier-config" : " ^1.4.5" ,
3232 "@adonisjs/tsconfig" : " ^2.0.0-next.0" ,
33+ "@ark/attest" : " ^0.55.0" ,
3334 "@japa/assert" : " ^4.1.1" ,
3435 "@japa/expect-type" : " ^2.0.3" ,
3536 "@japa/file-system" : " ^2.3.2" ,
Original file line number Diff line number Diff line change 1010/*
1111 * Pretty print complex types
1212 */
13- export type Prettify < T > = T extends Function
14- ? T
15- : Extract <
16- {
17- [ Key in keyof T ] : T [ Key ]
18- } ,
19- T
20- >
13+ export type Prettify < T > = {
14+ [ K in keyof T ] : T [ K ]
15+ } & { }
2116
2217/**
2318 * Primitive values
Original file line number Diff line number Diff line change 22 "extends" : " @adonisjs/tsconfig/tsconfig.package.json" ,
33 "compilerOptions" : {
44 "rootDir" : " ./" ,
5+ "moduleResolution" : " nodenext" ,
56 "outDir" : " ./build"
67 }
78}
You can’t perform that action at this time.
0 commit comments