Skip to content

Commit e3a10d7

Browse files
Fixed: TS2Swift was emitting class types twice (once via visitClassDecl, then again via visitStructuredType when the same type showed up in seenTypes), which caused the duplicate _Weird interface in InvalidPropertyNames.Import.d.ts.
- Change: `Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js` now records emitted class names in `emittedStructuredTypeNames` so the structured-type pass skips them. - Snapshots refreshed; `swift test --package-path ./Plugins/BridgeJS` passes.
1 parent 0497d26 commit e3a10d7

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

Plugins/BridgeJS/Sources/TS2Swift/JavaScript/src/processor.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,9 @@ export class TypeProcessor {
461461
if (!node.name) return;
462462

463463
const jsName = node.name.text;
464+
if (this.emittedStructuredTypeNames.has(jsName)) return;
465+
this.emittedStructuredTypeNames.add(jsName);
466+
464467
const swiftName = this.swiftTypeName(jsName);
465468
const escapedJSName = jsName.replaceAll("\\", "\\\\").replaceAll("\"", "\\\\\"");
466469
const annotation = jsName !== swiftName ? `@JSClass(jsName: "${escapedJSName}")` : "@JSClass";

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/InvalidPropertyNames.Import.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ export interface WeirdNaming {
2323
export interface _Weird {
2424
"method-with-dashes"(): void;
2525
}
26-
export interface _Weird {
27-
}
2826
export type Exports = {
2927
}
3028
export type Imports = {

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/InvalidPropertyNames.Macros.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,3 @@
4242
}
4343
4444
@JSFunction func createWeirdClass() throws (JSException) -> _Weird
45-
46-
@JSClass(jsName: "$Weird") struct _Weird {
47-
}

0 commit comments

Comments
 (0)