Skip to content

Commit

Permalink
Revision 0.29.3 (#487)
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 authored Jul 3, 2023
1 parent c8d8a70 commit da10cc0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sinclair/typebox",
"version": "0.29.2",
"version": "0.29.3",
"description": "JSONSchema Type Builder with Static Type Resolution for TypeScript",
"keywords": [
"typescript",
Expand Down
4 changes: 2 additions & 2 deletions src/typebox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,9 @@ export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, In
// TKeyOf
// --------------------------------------------------------------------------
// prettier-ignore
export type TKeyOfProperties<T extends TSchema> = Static<T> extends infer S
export type TKeyOfProperties<T extends TSchema> = Discard<Static<T> extends infer S
? UnionToTuple<{[K in keyof S]: TLiteral<Assert<K, TLiteralValue>>}[keyof S]>
: []
: [], undefined> // note: optional properties produce undefined types in tuple result. discard.
// prettier-ignore
export type TKeyOfIndicesArray<T extends TSchema[]> = UnionToTuple<keyof T & `${number}`>
// prettier-ignore
Expand Down
9 changes: 9 additions & 0 deletions test/static/keyof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,12 @@ import { Type } from '@sinclair/typebox'
const K = Type.KeyOf(T)
Expect(K).ToInfer<'a' | 'b' | 'c' | 'd'>()
}
{
const T = Type.Object({
a: Type.Optional(Type.String()),
b: Type.Optional(Type.String()),
c: Type.Optional(Type.String()),
})
const K = Type.KeyOf(T)
Expect(K).ToInfer<'a' | 'b' | 'c'>()
}

0 comments on commit da10cc0

Please sign in to comment.