SynthLuvr
SynthLuvr
Aarktype
Created by SynthLuvr on 9/2/2024 in #questions
Compiling to JavaScript results in `any` type
Ok I got it working. I needed to have arktype versions matching in both packages, even though arktype is set as a peer dependency
7 replies
Aarktype
Created by SynthLuvr on 9/2/2024 in #questions
Compiling to JavaScript results in `any` type
It gets worse, anything returned by MorphType is any
7 replies
Aarktype
Created by SynthLuvr on 9/2/2024 in #questions
Compiling to JavaScript results in `any` type
Using:
{
"compilerOptions": {
"baseUrl": "./",
"target": "ESNext",
"module": "NodeNext",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": false,
"moduleResolution": "nodenext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist"
},
"include": ["**/*"],
"exclude": ["node_modules", "dist"]
}
{
"compilerOptions": {
"baseUrl": "./",
"target": "ESNext",
"module": "NodeNext",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": false,
"moduleResolution": "nodenext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist"
},
"include": ["**/*"],
"exclude": ["node_modules", "dist"]
}
7 replies
Aarktype
Created by SynthLuvr on 9/2/2024 in #questions
Compiling to JavaScript results in `any` type
hmm I'm still getting this issue with latest ArkType
const SeedToWallet = type(/^([a-z]+\s){23}[a-z]+$/).pipe((phrase, ctx) => {
const wallet = mayFail(() => walletFromSeed(phrase));
return wallet.ok ? wallet.data : ctx.error("valid mmemonic");
});

type Seed = typeof SeedToWallet.inferIn;
const SeedToWallet = type(/^([a-z]+\s){23}[a-z]+$/).pipe((phrase, ctx) => {
const wallet = mayFail(() => walletFromSeed(phrase));
return wallet.ok ? wallet.data : ctx.error("valid mmemonic");
});

type Seed = typeof SeedToWallet.inferIn;
Seed is correctly type string here. Compiled to JavaScript:
declare const Seed: import("arktype/internal/methods/morph.ts").MorphType<(In: string) => import("arktype/internal/attributes.ts").Out<FromSeed>, {}>;
type Seed = typeof Seed.inferIn;
declare const Seed: import("arktype/internal/methods/morph.ts").MorphType<(In: string) => import("arktype/internal/attributes.ts").Out<FromSeed>, {}>;
type Seed = typeof Seed.inferIn;
Seed is now type any
7 replies
Aarktype
Created by SynthLuvr on 1/25/2025 in #questions
`.out` is inferring `unknown`
.out.infer does not work, which I thought it used to work like this
4 replies
Aarktype
Created by SynthLuvr on 1/25/2025 in #questions
`.out` is inferring `unknown`
hmm, seems it has changed to .inferOut, which works fine
4 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Property 'describe' does not exist on type 'instantiateType<inferTupleExpression<...>, {}>'
This works great, except in this situation:
function create<T extends number>(code: T): Type<T>
function create(code: number): type.Any {
return type(["===", code]).describe("abc")
}

function inner<T extends number>(code: T) {
const codeType = create(code);
type({codeType})
}
function create<T extends number>(code: T): Type<T>
function create(code: number): type.Any {
return type(["===", code]).describe("abc")
}

function inner<T extends number>(code: T) {
const codeType = create(code);
type({codeType})
}
13 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Piping types no longer works
Ok that works. I think it was broken in the past which is why I had to wrap it, but seems to be working now
12 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Property 'describe' does not exist on type 'instantiateType<inferTupleExpression<...>, {}>'
I think updating from 2.0.0-rc.12 to 2.0.0-rc.13 is the real problem here, so maybe I'll stick with the older version for now
13 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Property 'describe' does not exist on type 'instantiateType<inferTupleExpression<...>, {}>'
ugh, that creates more problems
13 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Property 'describe' does not exist on type 'instantiateType<inferTupleExpression<...>, {}>'
I really dislike it but the only way I can figure out how to fix the issue is to do this:
const Dummy = type({});
type Dummy = typeof Dummy;
const codeType = ["===", code] as const;
type codeType = typeof codeType;

return {
error: type({
message,
code: (type(["===", code]) as Dummy).describe(
`Always equal to ${code}`,
) as unknown as codeType,
}),
};
const Dummy = type({});
type Dummy = typeof Dummy;
const codeType = ["===", code] as const;
type codeType = typeof codeType;

return {
error: type({
message,
code: (type(["===", code]) as Dummy).describe(
`Always equal to ${code}`,
) as unknown as codeType,
}),
};
13 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Property 'describe' does not exist on type 'instantiateType<inferTupleExpression<...>, {}>'
I'm a bit stuck on this, not sure how to call describe without messing up the types
13 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Property 'describe' does not exist on type 'instantiateType<inferTupleExpression<...>, {}>'
This is annoying, casting doesn't work because it changes the type definition
13 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Property 'describe' does not exist on type 'instantiateType<inferTupleExpression<...>, {}>'
Casting works
const Dummy = type(["===", 200]);
const create = <T extends number>(code: T) =>
(type(["===", code]) as Dummy).describe("abc") as Type<T>;
const Dummy = type(["===", 200]);
const create = <T extends number>(code: T) =>
(type(["===", code]) as Dummy).describe("abc") as Type<T>;
13 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Piping types no longer works
Got it
const Letters = type("'a'|'b'|'c'");
const Letter = type("string").pipe((s, ctx) => {
const result = Letters(s);
return result instanceof type.errors
? ctx.error(result.at(0)!.expected!)
: result;
});
const Letters = type("'a'|'b'|'c'");
const Letter = type("string").pipe((s, ctx) => {
const result = Letters(s);
return result instanceof type.errors
? ctx.error(result.at(0)!.expected!)
: result;
});
12 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Piping types no longer works
hmm, not quite
12 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Piping types no longer works
import { type } from "arktype";

const Letters = type("'a'|'b'|'c'");
const Letter = type("string").pipe((s) => {
const result = Letters(s);
return result instanceof type.errors ? result.at(0)! : result;
});

console.log(Letter.assert("d"));
import { type } from "arktype";

const Letters = type("'a'|'b'|'c'");
const Letter = type("string").pipe((s) => {
const result = Letters(s);
return result instanceof type.errors ? result.at(0)! : result;
});

console.log(Letter.assert("d"));
This seems to produce the same behavior I'm accustomed to:
AggregateError: must be "a", "b" or "c" (was "d")
AggregateError: must be "a", "b" or "c" (was "d")
12 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Piping types no longer works
ctx.error(result.summary) works, but then duplicates the error AggregateError: must be must be "a", "b" or "c" (was "d") (was "d")
12 replies
Aarktype
Created by SynthLuvr on 9/28/2024 in #questions
Piping types no longer works
import { type } from "arktype";

const Letters = type("'a'|'b'|'c'");
const Letter = type("string").pipe((s, ctx) => {
const result = Letters(s);
return result instanceof type.errors ? ctx.error(result) : result;
});

console.log(Letter.assert("d"));
import { type } from "arktype";

const Letters = type("'a'|'b'|'c'");
const Letter = type("string").pipe((s, ctx) => {
const result = Letters(s);
return result instanceof type.errors ? ctx.error(result) : result;
});

console.log(Letter.assert("d"));
Produces:
description: node => `valid according to ${node.predicate.name || "an anonymous predicate"}`
^

TypeError: Cannot read properties of undefined (reading 'name')
description: node => `valid according to ${node.predicate.name || "an anonymous predicate"}`
^

TypeError: Cannot read properties of undefined (reading 'name')
12 replies
Aarktype
Created by SynthLuvr on 9/6/2024 in #questions
Type instantiation is excessively deep and possibly infinite
What would be cool is if we could do type("bigint>0n")
52 replies