Skip to content

Commit 4326481

Browse files
committed
BridgeJS: Fix TypeScript type definition generation for struct arguments
1 parent 549b727 commit 4326481

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,8 +1441,6 @@ public struct BridgeJSLink {
14411441
}
14421442
}
14431443
return type.tsType
1444-
case .swiftStruct(let name):
1445-
return name.components(separatedBy: ".").last ?? name
14461444
case .nullable(let wrapped, let kind):
14471445
let base = resolveTypeScriptType(wrapped, exportedSkeletons: exportedSkeletons)
14481446
return "\(base) | \(kind.absenceLiteral)"
@@ -3612,7 +3610,7 @@ extension BridgeType {
36123610
case .associatedValueEnum(let name):
36133611
return "\(name)Tag"
36143612
case .swiftStruct(let name):
3615-
return "\(name)Tag"
3613+
return name.components(separatedBy: ".").last ?? name
36163614
case .namespaceEnum(let name):
36173615
return name
36183616
case .swiftProtocol(let name):

Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClosure.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export type Exports = {
7070
TestProcessor: {
7171
new(transform: (arg0: string) => string): TestProcessor;
7272
}
73-
roundtripAnimal(animalClosure: (arg0: AnimalTag) => AnimalTag): (arg0: AnimalTag) => AnimalTag;
74-
roundtripOptionalAnimal(animalClosure: (arg0: AnimalTag | null) => AnimalTag | null): (arg0: AnimalTag | null) => AnimalTag | null;
73+
roundtripAnimal(animalClosure: (arg0: Animal) => Animal): (arg0: Animal) => Animal;
74+
roundtripOptionalAnimal(animalClosure: (arg0: Animal | null) => Animal | null): (arg0: Animal | null) => Animal | null;
7575
roundtripString(stringClosure: (arg0: string) => string): (arg0: string) => string;
7676
roundtripInt(intClosure: (arg0: number) => number): (arg0: number) => number;
7777
roundtripBool(boolClosure: (arg0: boolean) => boolean): (arg0: boolean) => boolean;

0 commit comments

Comments
 (0)