Skip to content

Commit 50b2a15

Browse files
committed
refactor: use slices.Contains to simplify code
Signed-off-by: tongjicoder <tongjicoder@icloud.com>
1 parent 1b88303 commit 50b2a15

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

internal/checker/mapper.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package checker
22

3-
import "github.com/microsoft/typescript-go/internal/core"
3+
import (
4+
"slices"
5+
6+
"github.com/microsoft/typescript-go/internal/core"
7+
)
48

59
// TypeMapperKind
610

@@ -158,10 +162,8 @@ func newArrayToSingleTypeMapper(sources []*Type, target *Type) *TypeMapper {
158162
}
159163

160164
func (m *ArrayToSingleTypeMapper) Map(t *Type) *Type {
161-
for _, s := range m.sources {
162-
if t == s {
163-
return m.target
164-
}
165+
if slices.Contains(m.sources, t) {
166+
return m.target
165167
}
166168
return t
167169
}

0 commit comments

Comments
 (0)