arktype

A

arktype

This is a friendly space centered around ArkType, TypeScript's 1:1 validator (https://github.com/arktypeio/arktype)

Join

out.summary returns only one error 2.0.0-dev.11

Hi, I am just wondering if I am using this correctly as I followed the new arktype tutorial I made the following schema and validated it However, it only gives me one error...

Referencing self

Hello, I have a type A ```ts const A = { hello: 'string', aArray: arrayOf(???)...

Export type to JSON and share it

Hello, I have two TS programs that should cooperate (A B), B import types and validates data, and A creates and "saves" the types. A rough idea ```ts // Program A import { type } from 'arktype' ...

False recursive reference

Anyone know how I can get past this false positive claiming I'm recursively referencing process.env in its base type? Since the value is just being used to compute the base type, not in the actual base type, this should be okay. ``` import { type } from "arktype"; ...

How to specify a property of type function?

In Typescript I have defined it like this: ```ts type User = { accounts: accounts?: (() => Promise<Account>)[]; }...

Why scope().compile().infer resolves to any?

I tried to follow the example here: https://arktype.io/docs/scopes Not sure if this is a bug or if I'm doing it wrong Stackblitz: https://stackblitz.com/edit/rzkceh-eodur9?file=demo.ts%3AL63,index.ts...

How to Union in scope()?

Union 1 will be resolved as I would expect to ts?: string | TimeStub | undefined;: ```ts export const myType = type({ "id?": "string",...

How to include an external class into an arktype type?

I tried ```ts import { TimeStub } from 'fauna'; // class const clientDocument = type({...

Are you recommending to create first ArkType types and derive from their TS types or vice versa?

Are you recommending to create first ArkType types and derive from their TS types or vice versa?

Array error message

Hello, I think I found an inconsistency in array errors: https://stackblitz.com/edit/vy55da?file=type.ts The tags error is: tags must be at least 3 characters (was 2) But should probably not be characters, but something like items....

Unions with optional params?

Are unions with optional params supported in arktype? Example: ```typescript import { type, union } from "arktype"...

ParseError: '3.0' was parsed as a number but could not be narrowed to a literal value.

I'm not sure yet, where does this come from, but does it say anything to you? ``` /projects/custom/hfl/node_modules/arktype/dist/cjs/utils/errors.js:25 throw new ParseError(message); ^...

CJS/ESM issue with arktype

I installed arktype. It's a ESM thing, and it broke my building process. To fix it, I had to switch to building with babel and had to set these values in tsconfig.json:: ``` "module": "ES2015", "moduleResolution": "Bundler"...

The inferred type of '... cannot be named without a reference to '../../../../node_modules/arktype/

I receive this strange message:
src/clients/client-amazon.ts:76:3 - error TS2742: The inferred type of 'get' cannot be named without a reference to '../../../../node_modules/arktype/dist/types/scopes/type'. This is likely not portable. A type annotation is necessary.
src/clients/client-amazon.ts:76:3 - error TS2742: The inferred type of 'get' cannot be named without a reference to '../../../../node_modules/arktype/dist/types/scopes/type'. This is likely not portable. A type annotation is necessary.
...

Need help with typing scope output properly

I've got one crazy idea to declare types as scopes to access validators independently

non-empty string - how to?

How to declare a schema with 'string' type but... not empty, i.e. which is banning ""?

How to incorporate existing type?

I have a type imported from a third-party API and I'd like to build it in into my ark type: ```ts import { Foo } from 'fancy-api' const schema = type({...

How to declare an optional schema?

I wonder if it's possible to define a schema that is ok if data is undefined. E.g. in: ```ts declare function foo(a?: string)v void...

Can scopes validate?

Can scopes validate or they are only a collection of types?

How to properly make a property of a class type?

I tried this: ```ts class TokenManager {} const params = type({ tokenManager: type(['instanceof', TokenManager]),...