Skip to content

Commit b3dd43d

Browse files
committed
[fix] typebox clone requirement when extending Base
1 parent 56bf3e5 commit b3dd43d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/util/TypeBoxUtil.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,21 @@ export class TypeStringEnumType<T extends string[] | readonly string[]> extends
4242
super();
4343
this.enum = values;
4444
Object.assign(this, annotations);
45+
// create a non-enumerable property called annotations
46+
Object.defineProperty(this, "annotations", {
47+
value: annotations,
48+
enumerable: false,
49+
});
4550
}
4651

4752
public Check(value: unknown): value is T[number] {
4853
return typeof value === "string" && this.enum.includes(value);
4954
}
55+
56+
public Clone(): TypeStringEnumType<T> {
57+
// @ts-expect-error - annotations is not a property of TypeStringEnumType
58+
return new TypeStringEnumType(this.enum, this.annotations);
59+
}
5060
}
5161

5262
export const TypeStringEnum = <T extends string[] | readonly string[]>(

0 commit comments

Comments
 (0)