A
arktype2mo ago
PIat

Type definitions must be strings or objects (was undefined)

Hello! When importing a module that is using Arktype, I get the error Type definitions must be strings or objects (was undefined). I am not sure what it means. What should I be looking for to solve it?
10 Replies
ssalbdivad
ssalbdivad2mo ago
What specifically repros that error? That would be caused when you do something like type(undefined) Or type({foo: undefined})
PIat
PIatOP2mo ago
During instantiation or assertion?
ssalbdivad
ssalbdivad2mo ago
Instantiation when it parses the definition
PIat
PIatOP2mo ago
I am not sure what causes it, I will go through the types now and hopefully find it
ssalbdivad
ssalbdivad2mo ago
It's not a type-level issue (though maybe you mean runtime Types) it's probably a value that is typed as a string or something but is actually undefined Otherwise it would be a type error Or wait is it a type error? Hahaha I guess I should have asked that I forgot we give that error in parallel between runtime and types
PIat
PIatOP2mo ago
What about
type({})
type({})
Would this crash?
ssalbdivad
ssalbdivad2mo ago
No that's fine Is it a type or a runtime error though that is very important
PIat
PIatOP2mo ago
It's a runtime error
ssalbdivad
ssalbdivad2mo ago
Ahh okay Can you use a debugger and just go up the stack to see what definition was being parsed when it fails? That should be straightforward
PIat
PIatOP2mo ago
I think I found it: With a model a utility function throws: TypeError: Cannot convert undefined or null to object
export function fromEnum<T extends object>(arg: T) {
return ['===', ...Object.values(arg)] as ['===', ...Array<T[keyof T]>]
}
export function fromEnum<T extends object>(arg: T) {
return ['===', ...Object.values(arg)] as ['===', ...Array<T[keyof T]>]
}
So it's not an Arktype error
Want results from more Discord servers?
Add your server