Skip to content

Commit ad36901

Browse files
authored
feat: 'NotNullMaps' to handle generic arguments (#22)
1 parent 34b871e commit ad36901

File tree

5 files changed

+26
-1
lines changed

5 files changed

+26
-1
lines changed

bindings/walk/walk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func Walk(v Visitor, node bindings.Node) {
5353
Walk(v, n.Type)
5454
Walk(v, n.Initializer)
5555
case *bindings.ReferenceType:
56-
// noop
56+
walkList(v, n.Arguments)
5757
case *bindings.LiteralKeyword:
5858
// noop
5959
case *bindings.LiteralType:

convert_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ func TestGeneration(t *testing.T) {
106106
muts := strings.Split(strings.TrimSpace(string(mutsCSV)), ",")
107107
for _, m := range muts {
108108
switch m {
109+
case "NotNullMaps":
110+
mutations = append(mutations, config.NotNullMaps)
109111
case "EnumAsTypes":
110112
mutations = append(mutations, config.EnumAsTypes)
111113
case "EnumLists":

testdata/notnullmap/mutations

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
NotNullMaps

testdata/notnullmap/notnullmap.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package notnullmap
2+
3+
type Foo struct {
4+
Bar map[string]bool
5+
Nested GenericFoo[map[string]int]
6+
}
7+
8+
type GenericFoo[T any] struct {
9+
Bar T
10+
}

testdata/notnullmap/notnullmap.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Code generated by 'guts'. DO NOT EDIT.
2+
3+
// From notnullmap/notnullmap.go
4+
interface Foo {
5+
Bar: Record<string, boolean>;
6+
Nested: GenericFoo<Record<string, number>>;
7+
}
8+
9+
// From notnullmap/notnullmap.go
10+
interface GenericFoo<T extends any> {
11+
Bar: T;
12+
}

0 commit comments

Comments
 (0)