Repository navigation
In Type.Script, the with keyword replaced Options?
#1646
|
Suddenly Options refinements stopped working in Type.Script after updating to 1.3.x. |
Replies: 2 comments
|
@sleewoo Hi!
Yes, sorry about the change, I was a bit uneasy about making it. However the new // --------------------------------------------------------------------
// 1.0
// --------------------------------------------------------------------
const T = Type.Options(Type.String(), { format: 'email' }) // Type.*
const S = Type.Script(`Options<string, { format: 'email' }>`) // Script
// --------------------------------------------------------------------
// 1.3
// --------------------------------------------------------------------
const T = Type.With(Type.String(), { format: 'email' }) // Type.*
const S = Type.Script(`string with { format: 'email' }`) // ScriptThe change was made because // The following wasn't possible in 1.0 because Options would
// override the mechanism to ascribe options to schematics. This
// was the main reason for the change (fixed in 1.3)
const { Options } = Type.Script(`
type Options = {
x: string
y: string
}
`)There was also some consideration given to a possible // The 'with' syntax enable all constraints and annotations
const A = Type.Script(`number with { minimum: 10, maximum: 20 }`)
// The 'where` syntax would be for constraints only
const B = Type.Script(`number where x => x <= 10 && x >= 20`)However it was decided that Again, sorry about the change. If you need some help with updating, feel free to ping. |
and that's great and consistent! |
@sleewoo Hi!
Yes, sorry about the change, I was a bit uneasy about making it. However the new
withkeyword syntax does replaceOptionsand will be the final syntax moving forward.