From 1ee9a1bdae21e830b9530900ae60b24bfd684e17 Mon Sep 17 00:00:00 2001
From: Aryan Bhosale <36108149+aryanbhosale@users.noreply.github.com>
Date: Sun, 25 Aug 2024 17:25:34 +0530
Subject: [PATCH 1/2] correct typedef of Route

---
 types/router.d.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/types/router.d.ts b/types/router.d.ts
index a334bc95f..d458a6e2e 100644
--- a/types/router.d.ts
+++ b/types/router.d.ts
@@ -411,7 +411,7 @@ export interface Route {
   path: string
   name?: string | null
   hash: string
-  query: Dictionary<string | (string | null)[]>
+  query: Dictionary<string | null | (string | null)[]>
   params: Dictionary<string>
   fullPath: string
   matched: RouteRecord[]

From dee25cf83d47efc0e752cd24bfa06817bcb3470b Mon Sep 17 00:00:00 2001
From: Aryan Bhosale <36108149+aryanbhosale@users.noreply.github.com>
Date: Tue, 27 Aug 2024 16:21:08 +0530
Subject: [PATCH 2/2] test for updated typedef for the query property

---
 types/test/route-query.spec.ts | 103 +++++++++++++++++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 types/test/route-query.spec.ts

diff --git a/types/test/route-query.spec.ts b/types/test/route-query.spec.ts
new file mode 100644
index 000000000..9f2f057b3
--- /dev/null
+++ b/types/test/route-query.spec.ts
@@ -0,0 +1,103 @@
+import VueRouter from '../index'
+import { Route } from '../index'
+
+const component = { template: '<div>test</div>' }
+
+const router = new VueRouter({
+  routes: [
+    { path: '/:id', component }
+  ]
+})
+
+describe('Route query types', () => {
+  it('should handle string query parameter', () => {
+    const route: Route = {
+      path: '/test',
+      query: { foo: 'bar' },
+      params: {},
+      fullPath: '/test?foo=bar',
+      name: null,
+      hash: '',
+      matched: [],
+      redirectedFrom: undefined,
+      meta: {}
+    }
+    
+    expect(typeof route.query.foo).toBe('string')
+  })
+
+  it('should handle null query parameter', () => {
+    const route: Route = {
+      path: '/test',
+      query: { foo: null },
+      params: {},
+      fullPath: '/test?foo',
+      name: null,
+      hash: '',
+      matched: [],
+      redirectedFrom: undefined,
+      meta: {}
+    }
+    
+    expect(route.query.foo).toBeNull()
+  })
+
+  it('should handle array of strings query parameter', () => {
+    const route: Route = {
+      path: '/test',
+      query: { foo: ['bar', 'baz'] },
+      params: {},
+      fullPath: '/test?foo=bar&foo=baz',
+      name: null,
+      hash: '',
+      matched: [],
+      redirectedFrom: undefined,
+      meta: {}
+    }
+    
+    expect(Array.isArray(route.query.foo)).toBe(true)
+    expect(route.query.foo).toEqual(['bar', 'baz'])
+  })
+
+  it('should handle array with null query parameter', () => {
+    const route: Route = {
+      path: '/test',
+      query: { foo: ['bar', null] },
+      params: {},
+      fullPath: '/test?foo=bar&foo',
+      name: null,
+      hash: '',
+      matched: [],
+      redirectedFrom: undefined,
+      meta: {}
+    }
+    
+    expect(Array.isArray(route.query.foo)).toBe(true)
+    expect(route.query.foo).toEqual(['bar', null])
+  })
+
+  it('should handle mixed query parameters', () => {
+    const route: Route = {
+      path: '/test',
+      query: { 
+        string: 'value',
+        nullValue: null,
+        stringArray: ['one', 'two'],
+        mixedArray: ['three', null]
+      },
+      params: {},
+      fullPath: '/test?string=value&nullValue&stringArray=one&stringArray=two&mixedArray=three&mixedArray',
+      name: null,
+      hash: '',
+      matched: [],
+      redirectedFrom: undefined,
+      meta: {}
+    }
+    
+    expect(typeof route.query.string).toBe('string')
+    expect(route.query.nullValue).toBeNull()
+    expect(Array.isArray(route.query.stringArray)).toBe(true)
+    expect(Array.isArray(route.query.mixedArray)).toBe(true)
+    expect(route.query.mixedArray).toEqual(['three', null])
+  })
+})