From 7dc339229b8700c0ae8d6862dc9e1cf01cc55ed5 Mon Sep 17 00:00:00 2001 From: Krzysztof Rodak Date: Thu, 5 Feb 2026 14:07:02 +0100 Subject: [PATCH] BridgeJS: Add missing `function` keyword for namespace function declarations in TypeScript --- Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift | 2 +- .../BridgeJSLinkTests/EnumNamespace.Global.d.ts | 6 +++--- .../__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts | 2 +- .../__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts | 2 +- .../BridgeJSLinkTests/StaticFunctions.Global.d.ts | 2 +- .../Exporting-Swift/Exporting-Swift-Static-Functions.md | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 9303962a6..838407992 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -3094,7 +3094,7 @@ extension BridgeJSLink { let sortedFunctions = childNode.content.functions.sorted { $0.name < $1.name } for function in sortedFunctions { let signature = - "\(function.name)\(renderTSSignatureCallback(function.parameters, function.returnType, function.effects));" + "function \(function.name)\(renderTSSignatureCallback(function.parameters, function.returnType, function.effects));" printer.write(signature) } let sortedProperties = childNode.content.staticProperties.sorted { $0.name < $1.name } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts index f1dc0a926..be77e759c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/EnumNamespace.Global.d.ts @@ -61,9 +61,9 @@ declare global { namespace Services { namespace Graph { namespace GraphOperations { - createGraph(rootId: number): number; - nodeCount(graphId: number): number; - validate(graphId: number): boolean; + function createGraph(rootId: number): number; + function nodeCount(graphId: number): number; + function validate(graphId: number): boolean; } } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts index 67a6eebcf..6f18e53ed 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/MixedModules.d.ts @@ -12,7 +12,7 @@ declare global { constructor(); greet(): string; } - globalFunction(): string; + function globalFunction(): string; } } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts index cdf83f36d..77d9cc0e9 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Namespaces.Global.d.ts @@ -9,7 +9,7 @@ export {}; declare global { namespace MyModule { namespace Utils { - namespacedFunction(): string; + function namespacedFunction(): string; } } namespace Utils { diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts index 069c1628c..a2f1c7d6d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StaticFunctions.Global.d.ts @@ -33,7 +33,7 @@ export {}; declare global { namespace Utils { namespace String { - uppercase(text: string): string; + function uppercase(text: string): string; } } } diff --git a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Static-Functions.md b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Static-Functions.md index 00e7c1f22..b6f680d1f 100644 --- a/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Static-Functions.md +++ b/Sources/JavaScriptKit/Documentation.docc/Articles/BridgeJS/Exporting-Swift/Exporting-Swift-Static-Functions.md @@ -140,7 +140,7 @@ Generated TypeScript definitions: declare global { namespace Utils { namespace String { - uppercase(text: string): string; + function uppercase(text: string): string; } } }