Skip to content

Commit af935d0

Browse files
authored
route-pattern: fix benchmarks for types (#11055)
1 parent 65baadd commit af935d0

File tree

4 files changed

+17
-12
lines changed

4 files changed

+17
-12
lines changed

packages/route-pattern/bench/types/href.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ bench('href > complex route', () => {
1717
}).types([4575, 'instantiations'])
1818

1919
bench('href > mediarss', () => {
20-
type Route = keyof typeof import('../routes/mediarss.ts').routes
21-
let routes: { [route in Route]: RoutePattern<route> } = {} as any
20+
type Routes = typeof import('../routes/mediarss.ts').routes
21+
let routes: { [route in keyof Routes]: RoutePattern<Routes[route]> } = {} as any
22+
23+
// @ts-expect-error missing required params: 'token'
24+
routes.feed.href()
25+
// @ts-expect-error missing required params: 'token'
26+
routes.feed.href({ extra: '123' })
2227

2328
routes.feed.href({ token: '123' })
2429
routes.media.href({ token: '123', path: 'users' })
@@ -55,4 +60,4 @@ bench('href > mediarss', () => {
5560
routes.adminApiMediaStream.href({ path: 'users' })
5661
routes.adminApiMediaUpload.href()
5762
routes.adminApiArtwork.href({ path: 'users' })
58-
}).types([39583, 'instantiations'])
63+
}).types([79421, 'instantiations'])

packages/route-pattern/bench/types/join.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ bench('Join', () => {
1717

1818
bench('join > mediarss', () => {
1919
const other = '/comments/:commentId'
20-
type Route = keyof typeof import('../routes/mediarss.ts').routes
21-
let routes: { [route in Route]: RoutePattern<route> } = {} as any
20+
type Routes = typeof import('../routes/mediarss.ts').routes
21+
let routes: { [route in keyof Routes]: RoutePattern<Routes[route]> } = {} as any
2222

2323
routes.feed.join(other)
2424
routes.media.join(other)
@@ -55,4 +55,4 @@ bench('join > mediarss', () => {
5555
routes.adminApiMediaStream.join(other)
5656
routes.adminApiMediaUpload.join(other)
5757
routes.adminApiArtwork.join(other)
58-
}).types([44665, 'instantiations'])
58+
}).types([81580, 'instantiations'])

packages/route-pattern/bench/types/new.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ bench('new > complex route', () => {
1616
}).types([3, 'instantiations'])
1717

1818
bench('new > mediarss', () => {
19-
type Route = keyof typeof import('../routes/mediarss.ts').routes
20-
let routes: { [route in Route]: RoutePattern<route> } = {} as any
19+
type Routes = typeof import('../routes/mediarss.ts').routes
20+
let routes: { [route in keyof Routes]: RoutePattern<Routes[route]> } = {} as any
2121

2222
routes.feed
2323
routes.media
@@ -54,4 +54,4 @@ bench('new > mediarss', () => {
5454
routes.adminApiMediaStream
5555
routes.adminApiMediaUpload
5656
routes.adminApiArtwork
57-
}).types([64, 'instantiations'])
57+
}).types([128, 'instantiations'])

packages/route-pattern/bench/types/params.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ bench('params > complex route', () => {
1919
}).types([3804, 'instantiations'])
2020

2121
bench('params > mediarss', () => {
22-
type Route = keyof typeof import('../routes/mediarss.ts').routes
23-
let routes: { [route in Route]: RoutePattern<route> } = {} as any
22+
type Routes = typeof import('../routes/mediarss.ts').routes
23+
let routes: { [route in keyof Routes]: RoutePattern<Routes[route]> } = {} as any
2424
let url: URL = {} as any
2525

2626
routes.feed.match(url)?.params
@@ -58,4 +58,4 @@ bench('params > mediarss', () => {
5858
routes.adminApiMediaStream.match(url)?.params
5959
routes.adminApiMediaUpload.match(url)?.params
6060
routes.adminApiArtwork.match(url)?.params
61-
}).types([39534, 'instantiations'])
61+
}).types([74851, 'instantiations'])

0 commit comments

Comments
 (0)