-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to have an Object+Dict? #60
Comments
@lazharichir Hi, good spotting. There has recently been some updates to Note a const Metadata = Type.Object({
provider: Type.Union([Type.Literal(`gcs`), Type.Literal(`s3`)]),
bucket: Type.String({ minLength: 1 }),
name: Type.String({ minLength: 1 }),
extra: Type.Dict(Type.Any()) // should work ok
}) Thanks for letting me know! |
No worries! In the meantime I will use an untyped Dict and will type it later once this is fixed. Thanks for the quick reply @sinclairzx81 ! |
@lazharichir Have taken another look at this tonight and I don't think this is a trivially resolvable issue. I have explored a couple of approaches, one constraining to Am going to move this issue from |
+1 would love this feature as well 🙂 |
Hi everyone. Will be closing off this issue shortly as I've just published a new version of TypeBox that deprecates The String Keystype T = Record<string, number> // typescript
const T = Type.Record(Type.String(), Type.Number()) // typebox - replaces Type.Dict()
type T = { [key: string]: number } // static Number Keystype T = Record<number, number> // typescript
const T = Type.Record(Type.Number(), Type.Number()) // typebox
type T = { [key: number]: number } // static Literal Keystype T = Record<'a' | 'b' | 'c', number> // typescript
const K = Type.Union([
Type.Literal('a'),
Type.Literal('b'),
Type.Literal('c'),
])
const T = Type.Record(K, Type.Number()) // typebox
type T = {
a: number,
b: number,
c: number
} // static Unfortunately, I have not found a solution to allow Thanks for raising this issue. It's been quite the journey figuring out how to provide better support for this, so I hope the new Many Thanks |
I'll check the new types out, thanks for trying your best. Stay well, L |
Hello, basically the desire here is to get the below type:
I've tried to do:
But it gives me an error on
Type.Dict(Type.Any()),
:Let me know if I have missed something!
Thank you!
The text was updated successfully, but these errors were encountered: