@@ -261,6 +261,7 @@ export class TypeProcessor {
261261 if ( ! isExported ) return ;
262262
263263 const fromArg = this . renderDefaultJSImportFromArgument ( ) ;
264+ const isConst = ( node . declarationList . flags & ts . NodeFlags . Const ) !== 0 ;
264265
265266 for ( const decl of node . declarationList . declarations ) {
266267 if ( ! ts . isIdentifier ( decl . name ) ) continue ;
@@ -270,13 +271,30 @@ export class TypeProcessor {
270271 const swiftVarName = this . renderIdentifier ( swiftName ) ;
271272
272273 const type = this . checker . getTypeAtLocation ( decl ) ;
273- const swiftType = this . visitType ( type , decl ) ;
274274
275275 /** @type {string[] } */
276276 const args = [ ] ;
277277 const jsNameArg = this . renderOptionalJSNameArg ( jsName , swiftName ) ;
278278 if ( jsNameArg ) args . push ( jsNameArg ) ;
279279 if ( fromArg ) args . push ( fromArg ) ;
280+ const callSignatures = type . getCallSignatures ( ) ;
281+
282+ if ( isConst && callSignatures . length > 0 ) {
283+ const signature = callSignatures [ 0 ] ;
284+ const parameters = signature . getParameters ( ) ;
285+ const parameterNameMap = this . buildParameterNameMap ( parameters ) ;
286+ const params = this . renderParameters ( parameters , decl ) ;
287+ const returnType = this . visitType ( signature . getReturnType ( ) , decl ) ;
288+ const effects = this . renderEffects ( { isAsync : false } ) ;
289+ const annotation = this . renderMacroAnnotation ( "JSFunction" , args ) ;
290+
291+ this . emitDocComment ( decl , { indent : "" , parameterNameMap } ) ;
292+ this . swiftLines . push ( `${ annotation } func ${ swiftVarName } (${ params } ) ${ effects } -> ${ returnType } ` ) ;
293+ this . swiftLines . push ( "" ) ;
294+ continue ;
295+ }
296+
297+ const swiftType = this . visitType ( type , decl ) ;
280298 const annotation = this . renderMacroAnnotation ( "JSGetter" , args ) ;
281299
282300 this . emitDocComment ( decl , { indent : "" } ) ;
0 commit comments