@@ -338,19 +338,28 @@ export async function generateTypings(srcDir: string, target: string, hackmudPat
338338 users . add ( basename ( dirent . name , ".key" ) )
339339
340340 const wildScripts : string [ ] = [ ]
341+ const wildAnyScripts : string [ ] = [ ]
341342 const allScripts : Record < string , string [ ] > = { }
343+ const allAnyScripts : Record < string , string [ ] > = { }
342344
343345 for ( const dirent of await readDir ( srcDir , { withFileTypes : true } ) )
344- if ( dirent . isFile ( ) && extname ( dirent . name ) == ".ts" )
345- wildScripts . push ( basename ( dirent . name , ".ts" ) )
346- else if ( dirent . isDirectory ( ) ) {
346+ if ( dirent . isFile ( ) ) {
347+ if ( extname ( dirent . name ) == ".ts" )
348+ wildScripts . push ( basename ( dirent . name , ".ts" ) )
349+ else if ( extname ( dirent . name ) == ".js" )
350+ wildAnyScripts . push ( basename ( dirent . name , ".js" ) )
351+ } else if ( dirent . isDirectory ( ) ) {
347352 const scripts : string [ ] = allScripts [ dirent . name ] = [ ]
353+ const anyScripts : string [ ] = allAnyScripts [ dirent . name ] = [ ]
348354
349355 users . add ( dirent . name )
350356
351357 for ( const file of await readDir ( resolvePath ( srcDir , dirent . name ) , { withFileTypes : true } ) )
352- if ( file . isFile ( ) && extname ( file . name ) == ".ts" )
353- scripts . push ( basename ( file . name , ".ts" ) )
358+ if ( file . isFile ( ) )
359+ if ( extname ( file . name ) == ".ts" )
360+ scripts . push ( basename ( file . name , ".ts" ) )
361+ else if ( extname ( file . name ) == ".js" )
362+ anyScripts . push ( basename ( file . name , ".js" ) )
354363 }
355364
356365 let o = ""
@@ -378,19 +387,26 @@ type WildFullsec = Record<string, () => ScriptFailure> & {
378387 for ( const script of wildScripts )
379388 o += `\t${ script } : Subscript<typeof $${ script } $>\n`
380389
390+ for ( const script of wildAnyScripts )
391+ o += `\t${ script } : (...args: any) => any\n`
392+
381393 o += "}\n\nexport type PlayerFullsec = {"
382394
383395 for ( const user of users ) {
384396 const scripts = allScripts [ user ]
397+ const anyScripts = allAnyScripts [ user ]
385398
386399 o += `\n\t${ user } : WildFullsec`
387400
388- if ( scripts && scripts . length ) {
401+ if ( ( scripts && scripts . length ) || ( anyScripts && anyScripts . length ) ) {
389402 o += " & {\n"
390403
391404 for ( const script of scripts )
392405 o += `\t\t${ script } : Subscript<typeof $${ user } $${ script } $>\n`
393406
407+ for ( const script of anyScripts )
408+ o += `\t\t${ script } : (...args: any) => any\n`
409+
394410 o += "\t}"
395411 }
396412
0 commit comments