File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
packages/react-router-dev Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -111,4 +111,24 @@ test.describe("typegen", () => {
111111 expect ( proc . stderr . toString ( ) ) . toBe ( "" ) ;
112112 expect ( proc . status ) . toBe ( 0 ) ;
113113 } ) ;
114+
115+ test ( "splat" , async ( ) => {
116+ const cwd = await createProject ( {
117+ "vite.config.ts" : viteConfig ,
118+ "app/routes/splat.$.tsx" : tsx `
119+ import type { Route } from "./+types.splat.$"
120+
121+ function assertType<T>(t: T) {}
122+
123+ export function loader({ params }: Route.LoaderArgs) {
124+ assertType<string>(params["*"])
125+ return null
126+ }
127+ ` ,
128+ } ) ;
129+ const proc = typecheck ( cwd ) ;
130+ expect ( proc . stdout . toString ( ) ) . toBe ( "" ) ;
131+ expect ( proc . stderr . toString ( ) ) . toBe ( "" ) ;
132+ expect ( proc . status ) . toBe ( 0 ) ;
133+ } ) ;
114134} ) ;
Original file line number Diff line number Diff line change @@ -182,12 +182,12 @@ function formattedParamsProperties(
182182 const properties = Object . entries ( params ) . map ( ( [ name , values ] ) => {
183183 if ( values . length === 1 ) {
184184 const isOptional = values [ 0 ] ;
185- return indent + ( isOptional ? `${ name } ?: string` : `${ name } : string` ) ;
185+ return indent + ( isOptional ? `" ${ name } " ?: string` : `" ${ name } " : string` ) ;
186186 }
187187 const items = values . map ( ( isOptional ) =>
188188 isOptional ? "string | undefined" : "string"
189189 ) ;
190- return indent + `${ name } : [${ items . join ( ", " ) } ]` ;
190+ return indent + `" ${ name } " : [${ items . join ( ", " ) } ]` ;
191191 } ) ;
192192
193193 // prettier-ignore
@@ -226,5 +226,8 @@ function parseParams(urlpath: string) {
226226 result [ param ] . push ( isOptional ) ;
227227 return ;
228228 } ) ;
229+
230+ const hasSplat = segments . at ( - 1 ) === "*" ;
231+ if ( hasSplat ) result [ "*" ] = [ false ] ;
229232 return result ;
230233}
You can’t perform that action at this time.
0 commit comments