Skip to content

Commit 9c386a6

Browse files
committed
remove unused mutation
1 parent 39e1aac commit 9c386a6

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

scripts/apitypings/main.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66

77
"github.com/coder/guts"
88
"github.com/coder/guts/bindings"
9-
"github.com/coder/guts/bindings/walk"
109
"github.com/coder/guts/config"
1110
)
1211

@@ -77,7 +76,6 @@ func TsMutations(ts *guts.Typescript) {
7776
// Omitempty + null is just '?' in golang json marshal
7877
// number?: number | null --> number?: number
7978
config.SimplifyOmitEmpty,
80-
SimplifyUndefinedUnionFields,
8179
)
8280
}
8381

@@ -149,32 +147,3 @@ func FixSerpentStruct(gen *guts.Typescript) {
149147
}
150148
})
151149
}
152-
153-
// SimplifyUndefinedUnionFields converts 'foo: string | undefined' to 'foo?: string'
154-
func SimplifyUndefinedUnionFields(gen *guts.Typescript) {
155-
gen.ForEach(func(key string, originalNode bindings.Node) {
156-
walk.Walk(questionTokenWalker{}, originalNode)
157-
})
158-
}
159-
160-
type questionTokenWalker struct {
161-
}
162-
163-
func (q questionTokenWalker) Visit(node bindings.Node) (w walk.Visitor) {
164-
switch n := node.(type) {
165-
case *bindings.PropertySignature:
166-
isUnion, ok := n.Type.(*bindings.UnionType)
167-
if !ok {
168-
return q
169-
}
170-
for i, t := range isUnion.Types {
171-
if keyword, ok := t.(*bindings.LiteralKeyword); ok && *keyword == bindings.KeywordUndefined {
172-
n.QuestionToken = true
173-
// Remove undefined
174-
isUnion.Types = append(isUnion.Types[:i], isUnion.Types[i+1:]...)
175-
break
176-
}
177-
}
178-
}
179-
return q
180-
}

0 commit comments

Comments
 (0)