MCPcopy Index your code
hub / github.com/coder/guts / Simplify

Function Simplify

bindings/declarations.go:65–80  ·  view source on GitHub ↗

Simplify removes duplicate type parameters

(p []*TypeParameter)

Source from the content-addressed store, hash-verified

63
64// Simplify removes duplicate type parameters
65func Simplify(p []*TypeParameter) ([]*TypeParameter, error) {
66 params := []*TypeParameter{}
67 set := make(map[string]bool)
68 for _, tp := range p {
69 ref := tp.Name.Ref()
70 if _, ok := set[ref]; !ok {
71 params = append(params, tp)
72 set[ref] = true
73
74 if union, ok := tp.Type.(*UnionType); ok {
75 simplifyUnionLiterals(union)
76 }
77 }
78 }
79 return params, nil
80}
81
82func simplifyUnionLiterals(union *UnionType) *UnionType {
83 types := []ExpressionType{}

Callers 2

buildStructMethod · 0.92
typescriptTypeMethod · 0.92

Calls 2

simplifyUnionLiteralsFunction · 0.85
RefMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…