mailliW
mailliW
Aarktype
Created by mailliW on 5/7/2025 in #questions
Is this a bug or user error? Re: Generic Argument Validation
import { scope } from "arktype"

const versionScope = scope({
ProductHashKey: "string",
ProductSortKey: "string",
Product: {
HK: "ProductHashKey",
SK: "ProductSortKey",
banana: "true"
},
"MasterVersion<EntityType extends string, Entity extends Record<string, unknown>, HashKeyPattern, SortKeyPattern = StandardVersionSortKey>":
{
"...": "Entity",
HK: "HashKeyPattern",
SK: "SortKeyPattern",
entityType: "EntityType",
currentVersion: "number.integer",
},
ProductMaster: "MasterVersion<'Product', Product, ProductHashKey, ProductSortKey>"
})
import { scope } from "arktype"

const versionScope = scope({
ProductHashKey: "string",
ProductSortKey: "string",
Product: {
HK: "ProductHashKey",
SK: "ProductSortKey",
banana: "true"
},
"MasterVersion<EntityType extends string, Entity extends Record<string, unknown>, HashKeyPattern, SortKeyPattern = StandardVersionSortKey>":
{
"...": "Entity",
HK: "HashKeyPattern",
SK: "SortKeyPattern",
entityType: "EntityType",
currentVersion: "number.integer",
},
ProductMaster: "MasterVersion<'Product', Product, ProductHashKey, ProductSortKey>"
})
Type '"MasterVersion<'Product', Product, ProductHashKey, ProductSortKey>"' is not assignable to type '"MasterVersion<EntityType, Entity, HashKeyPattern, SortKeyPattern, =, StandardVersionSortKey> requires exactly 6 args (got 4: 'Product', Product, ProductHashKey, ProductSortKey) "'.(2322)
main.ts(19, 5): The expected type comes from property 'ProductMaster' which is declared here on type 'validate<{ readonly ProductHashKey: "string"; readonly ProductSortKey: "string"; readonly Product: { readonly HK: "ProductHashKey"; readonly SK: "ProductSortKey"; readonly banana: "true"; }; readonly "MasterVersion<EntityType extends string, Entity extends Record<string, unknown>, HashKeyPattern, SortKeyPattern = St...'
(property) ProductMaster: "MasterVersion<EntityType, Entity, HashKeyPattern, SortKeyPattern, =, StandardVersionSortKey> requires exactly 6 args (got 4: 'Product', Product, ProductHashKey, ProductSortKey) "
Type '"MasterVersion<'Product', Product, ProductHashKey, ProductSortKey>"' is not assignable to type '"MasterVersion<EntityType, Entity, HashKeyPattern, SortKeyPattern, =, StandardVersionSortKey> requires exactly 6 args (got 4: 'Product', Product, ProductHashKey, ProductSortKey) "'.(2322)
main.ts(19, 5): The expected type comes from property 'ProductMaster' which is declared here on type 'validate<{ readonly ProductHashKey: "string"; readonly ProductSortKey: "string"; readonly Product: { readonly HK: "ProductHashKey"; readonly SK: "ProductSortKey"; readonly banana: "true"; }; readonly "MasterVersion<EntityType extends string, Entity extends Record<string, unknown>, HashKeyPattern, SortKeyPattern = St...'
(property) ProductMaster: "MasterVersion<EntityType, Entity, HashKeyPattern, SortKeyPattern, =, StandardVersionSortKey> requires exactly 6 args (got 4: 'Product', Product, ProductHashKey, ProductSortKey) "
2 replies
Aarktype
Created by mailliW on 5/7/2025 in #questions
Bracket Notation on Generics
No description
9 replies
Aarktype
Created by mailliW on 1/29/2025 in #questions
Is ArkType compatible with the overrides made in `@total-typescript/reset`, or will stuff break?
This library overrides some TypeScript defaults for perhaps what could be considered more sensible defaults (I guess that's subjective). I'm wondering if could possibly break ArkType somehow? https://www.totaltypescript.com/ts-reset-article
7 replies
Aarktype
Created by mailliW on 11/9/2024 in #questions
Defining and inferring a generic type defined inside a scope
I'm brand new to this library so I'm sorry if I'm doing something dumb, but I'm not sure how I can define a generic inside a scope. My broken code looks like this:
export const randomScope = scope({
foo: {
bar: "'biz'",
},
request: type("<t>", {
kind: "foo",
payload: "t",
}),
}).export();

export type Test = typeof randomScope.request.infer;
export const randomScope = scope({
foo: {
bar: "'biz'",
},
request: type("<t>", {
kind: "foo",
payload: "t",
}),
}).export();

export type Test = typeof randomScope.request.infer;
And I have the following errors:
No overload matches this call.
Overload 1 of 3, '(params: "<t>", def: validateObjectLiteral<{ readonly kind: "foo"; readonly payload: "t"; }, {}, baseGenericConstraints<[["t", unknown]]>>): Generic<...>', gave the following error.
Type '"foo"' is not assignable to type '"'foo' is unresolvable "'.
Overload 2 of 3, '(_0: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "Key" | "Record" | "Date" | "Array" | "false" | "never" | "null" | "true" | "unknown" | "keyof" | ... 24 more ... | "this", _1: IndexOneOperator): Type<...>', gave the following error.
Argument of type '"<t>"' is not assignable to parameter of type '"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "Key" | "Record" | "Date" | "Array" | "false" | "never" | "null" | "true" | "unknown" | "keyof" | ... 24 more ... | "this"'.ts(2769)
No overload matches this call.
Overload 1 of 3, '(params: "<t>", def: validateObjectLiteral<{ readonly kind: "foo"; readonly payload: "t"; }, {}, baseGenericConstraints<[["t", unknown]]>>): Generic<...>', gave the following error.
Type '"foo"' is not assignable to type '"'foo' is unresolvable "'.
Overload 2 of 3, '(_0: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "Key" | "Record" | "Date" | "Array" | "false" | "never" | "null" | "true" | "unknown" | "keyof" | ... 24 more ... | "this", _1: IndexOneOperator): Type<...>', gave the following error.
Argument of type '"<t>"' is not assignable to parameter of type '"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "Key" | "Record" | "Date" | "Array" | "false" | "never" | "null" | "true" | "unknown" | "keyof" | ... 24 more ... | "this"'.ts(2769)
Property 'infer' does not exist on type 'Generic<[["t", unknown]], { readonly kind: "foo"; readonly payload: "t"; }, {}, { foo: { bar: "biz"; }; request: bindGenericToScope<GenericAst<[["t", unknown]], { readonly kind: "foo"; readonly payload: "t"; }, {}, {}>, bootstrapAliases<...>>; }>'.ts(2339)
11 replies