| 80 | } |
| 81 | |
| 82 | func simplifyUnionLiterals(union *UnionType) *UnionType { |
| 83 | types := []ExpressionType{} |
| 84 | literalSet := map[string]bool{} |
| 85 | for _, arg := range union.Types { |
| 86 | switch v := arg.(type) { |
| 87 | case *LiteralKeyword: |
| 88 | key := v.String() |
| 89 | if _, ok := literalSet[key]; !ok { |
| 90 | literalSet[key] = true |
| 91 | types = append(types, arg) |
| 92 | } |
| 93 | default: |
| 94 | types = append(types, arg) |
| 95 | } |
| 96 | } |
| 97 | union.Types = types |
| 98 | return union |
| 99 | } |
| 100 | |
| 101 | // VariableStatement is a top level declaration of a variable |
| 102 | // var foo: string = "bar" |