Dimava
Dimava
Aarktype
Created by PIat on 9/17/2024 in #questions
Dynamic type based on another value
And a type with false
8 replies
Aarktype
Created by PIat on 9/17/2024 in #questions
Dynamic type based on another value
Or of a type with "true"
8 replies
Aarktype
Created by Dimava on 9/16/2024 in #questions
Generic with Narrow/Morph
export const UniqueArray = function <const def, const key extends keyof Type<type.infer<def>>['infer'] & string>(
def: type.validate<def, brandsScope['t']>, key: key,
) {
return type([
[def as { key: 'string' }, '[]'], ':', (v, ctx) => {
const set = new Set(v.map(e => e[key as 'key']))
if (set.size !== v.length)
ctx.mustBe(`with unique values of ${JSON.stringify(key)}`)
return true
},
])
}
export const UniqueArray = function <const def, const key extends keyof Type<type.infer<def>>['infer'] & string>(
def: type.validate<def, brandsScope['t']>, key: key,
) {
return type([
[def as { key: 'string' }, '[]'], ':', (v, ctx) => {
const set = new Set(v.map(e => e[key as 'key']))
if (set.size !== v.length)
ctx.mustBe(`with unique values of ${JSON.stringify(key)}`)
return true
},
])
}
this does work but I want to see how generics work
4 replies
Aarktype
Created by CodeHz on 9/12/2024 in #questions
Got syntax error in some browser
looks fine enough
26 replies
Aarktype
Created by CodeHz on 9/12/2024 in #questions
Got syntax error in some browser
oof 2020
26 replies
Aarktype
Created by CodeHz on 9/12/2024 in #questions
Got syntax error in some browser
🤔 How do you even run all the tests in the browser, lemme see
26 replies
Aarktype
Created by CodeHz on 9/12/2024 in #questions
Got syntax error in some browser
Do you have some even older browsers to try by chance? Would be interesting to see what the current limitations are
26 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
No description
37 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
okay idk see you tomorrow (╯°□°)╯︵ ┻━┻
37 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
that 💩 magic that doesn't allow me to use stuff! It come again! (╯°□°)╯︵ ┻━┻
37 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
No description
37 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
type({
LOG_SIZE_LIMIT_MB: type('string.integer.parse').pipe(type('number.integer > 0')),
)}
type({
LOG_SIZE_LIMIT_MB: type('string.integer.parse').pipe(type('number.integer > 0')),
)}
Me don't like this Why can't I just 'string.integer.parse > 0' Or at least ['string.integer.parse', '=>', 'number.integer > 0'] Or at least ['string.integer.parse', '=>', type('number.integer > 0')]
37 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
okay idk see you tomorrow (╯°□°)╯︵ ┻━┻
37 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
37 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
Why do I even have that lib: esnext there (╯°□°)╯︵ ┻━┻
37 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
Okay here's repro
{
"compilerOptions": {
"lib": ["esnext"],
"strictNullChecks": true
}
}
{
"compilerOptions": {
"lib": ["esnext"],
"strictNullChecks": true
}
}
37 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
Okay it was "moduleResolution": "node",
37 replies
Aarktype
Created by Dimava on 9/12/2024 in #questions
`string.integer.parsed` with limits
Okay this was tsconfig looking what exactly
37 replies