Skip to content

Commit aa89e2e

Browse files
committed
fix: detect not set format
1 parent 49bc714 commit aa89e2e

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

packages/router/src/unplugin/codegen/generateRouteResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ ${queryParams
402402
`Query param "${param.paramName}" in route "${node.fullPath}" uses raw param parser "${param.parser}" but specifies \`format: 'value'\`. The format is ignored because raw parsers always receive the array form.`
403403
)
404404
}
405-
const format = isRawParser ? 'array' : param.format
405+
const format = isRawParser ? 'array' : param.format || 'value'
406406
407407
const args = [
408408
`'${param.paramName}'`,

packages/router/src/unplugin/core/tree.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,25 +1138,25 @@ describe('Tree', () => {
11381138
{
11391139
paramName: 'search',
11401140
parser: null,
1141-
format: 'value',
1141+
format: null,
11421142
defaultValue: undefined,
11431143
},
11441144
{
11451145
paramName: 'limit',
11461146
parser: 'int',
1147-
format: 'value',
1147+
format: null,
11481148
defaultValue: '10',
11491149
},
11501150
{
11511151
paramName: 'tags',
11521152
parser: 'bool',
1153-
format: 'value',
1153+
format: null,
11541154
defaultValue: undefined,
11551155
},
11561156
{
11571157
paramName: 'other',
11581158
parser: null,
1159-
format: 'value',
1159+
format: null,
11601160
defaultValue: '"defaultValue"',
11611161
},
11621162
])
@@ -1188,13 +1188,13 @@ describe('Tree', () => {
11881188
expect(node.params[1]).toMatchObject({
11891189
paramName: 'tab',
11901190
parser: null,
1191-
format: 'value',
1191+
format: null,
11921192
defaultValue: undefined,
11931193
}) // query param
11941194
expect(node.params[2]).toMatchObject({
11951195
paramName: 'expand',
11961196
parser: 'bool',
1197-
format: 'value',
1197+
format: null,
11981198
defaultValue: 'false',
11991199
}) // query param
12001200
})

packages/router/src/unplugin/core/treeNodeValue.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ class _TreeNodeValueBase {
118118
queryParams.push({
119119
paramName,
120120
parser: config,
121-
format: 'value',
121+
format: null,
122122
})
123123
} else {
124124
queryParams.push({
125125
paramName,
126126
parser: config.parser || null,
127-
format: config.format || 'value',
127+
format: config.format || null,
128128
defaultValue: config.default,
129129
required: config.required,
130130
})
@@ -306,7 +306,7 @@ export interface TreeQueryParam {
306306

307307
parser: string | null
308308

309-
format: 'value' | 'array'
309+
format: 'value' | 'array' | null
310310

311311
/**
312312
* Expression to be passed as is to the default value of the param.

0 commit comments

Comments
 (0)