Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ struct DecodeFunctionBuilder {
if let (_, _) = try type.asDictionary() {
return try makeClosure()
}
if try !type.genericArguments().isEmpty {
return try makeClosure()
}
return .identifier(self.name(type: type))
}

Expand Down
5 changes: 1 addition & 4 deletions Sources/TSCodeModule/Expr/TSClosureExpr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ public struct TSClosureExpr: PrettyPrintable {
printer.write(": ")
returnType.print(printer: printer)
}
printer.writeLine(" => ")
printer.write(" => ")
body.print(printer: printer)
if !printer.isStartOfLine {
printer.writeLine("")
}
}
}
14 changes: 14 additions & 0 deletions Tests/CodableToTypeScriptTests/Generate/GenerateGenericTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -403,4 +403,18 @@ export function E_decode<T, T_JSON>(json: E_JSON<T_JSON>, T_decode: (json: T_JSO
)
}

func testNestedGenericParameter() throws {
try assertGenerate(
source: """
struct X<T> {
var a: T
var b: String
}

struct Y<T> {
var x: [X<T>]
}
""")
}

}