Skip to content

Commit 1510183

Browse files
committed
Add some more to test
1 parent fd75872 commit 1510183

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

coderd/util/slice/slice.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ func Overlap[T comparable](a []T, b []T) bool {
2525
// Unique returns a new slice with all duplicate elements removed.
2626
// This is a slow function on large lists.
2727
// TODO: Sort elements and implement a faster search algorithm if we
28-
//
29-
// really start to use this.
28+
// really start to use this.
3029
func Unique[T comparable](a []T) []T {
3130
cpy := make([]T, 0, len(a))
3231
for _, v := range a {

scripts/apitypings/testdata/generics/generics.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@ type Custom interface {
1212

1313
// StaticGeneric has all generic fields defined in the field
1414
type StaticGeneric struct {
15-
Static GenericFields[string, int, time.Duration] `json:"static"`
15+
Static GenericFields[string, int, time.Duration, string] `json:"static"`
1616
}
1717

1818
// DynamicGeneric can has some dynamic fields
19-
type DynamicGeneric[C comparable, A any] struct {
20-
Dynamic GenericFields[C, A, string] `json:"dynamic"`
21-
Comparable C `json:"comparable"`
19+
type DynamicGeneric[C comparable, A any, S Single] struct {
20+
Dynamic GenericFields[C, A, string, S] `json:"dynamic"`
21+
Comparable C `json:"comparable"`
2222
}
2323

24-
type GenericFields[C comparable, A any, T Custom] struct {
24+
type GenericFields[C comparable, A any, T Custom, S Single] struct {
2525
Comparable C `json:"comparable"`
2626
Any A `json:"any"`
2727

28-
Custom T `json:"custom"`
29-
Again T `json:"again"`
28+
Custom T `json:"custom"`
29+
Again T `json:"again"`
30+
SingleContraint S `json:"single_constraint"`
3031
}

scripts/apitypings/testdata/generics/generics.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
// Code generated by 'make coder/scripts/apitypings/main.go'. DO NOT EDIT.
22

33
// From codersdk/generics.go
4-
export interface DynamicGeneric<C extends comparable, A extends any> {
5-
readonly dynamic: GenericFields<C, A, string>
4+
export interface DynamicGeneric<C extends comparable, A extends any, S extends Single> {
5+
readonly dynamic: GenericFields<C, A, string, S>
66
readonly comparable: C
77
}
88

99
// From codersdk/generics.go
10-
export interface GenericFields<C extends comparable, A extends any, T extends Custom> {
10+
export interface GenericFields<C extends comparable, A extends any, T extends Custom, S extends Single> {
1111
readonly comparable: C
1212
readonly any: A
1313
readonly custom: T
1414
readonly again: T
15+
readonly single_constraint: S
1516
}
1617

1718
// From codersdk/generics.go
1819
export interface StaticGeneric {
19-
readonly static: GenericFields<string, number, number>
20+
readonly static: GenericFields<string, number, number, string>
2021
}
2122

2223
// From codersdk/generics.go

0 commit comments

Comments
 (0)