a collection of lightweight TypeScript packages for AT Protocol, the protocol powering Bluesky
atproto bluesky typescript npm

fix(lexicons): recursive type error from Standard Schema implementation

mary.my.id 17c6f4a0 ccfa8f59

verified
Changed files
+14 -4
.changeset
packages
lexicons
lexicons
lib
validations
+7
.changeset/deep-boats-shave.md
··· 1 + --- 2 + '@atcute/lexicons': patch 3 + --- 4 + 5 + fix recursive type error 6 + 7 + messed up how I implemented Standard Schema support.
+7 -4
packages/lexicons/lexicons/lib/validations/index.ts
··· 131 131 type MatcherResult = undefined | Ok<unknown> | IssueTree; 132 132 type Matcher = (input: unknown, flags: number) => MatcherResult; 133 133 134 - type LexStandardSchema<T extends BaseSchema> = StandardSchemaV1.Props<InferInput<T>, InferOutput<T>>; 134 + type LexStandardSchemaResult<T extends BaseSchema> = StandardSchemaV1.Result<InferOutput<T>>; 135 + 136 + interface LexStandardSchema<T extends BaseSchema> extends StandardSchemaV1.Props<unknown> { 137 + readonly validate: (value: unknown) => LexStandardSchemaResult<T> | Promise<LexStandardSchemaResult<T>>; 138 + readonly types?: StandardSchemaV1.Types<InferInput<T>, InferOutput<T>>; 139 + } 135 140 136 141 export interface BaseSchema<TInput = unknown, TOutput = TInput> { 137 142 readonly kind: 'schema'; ··· 379 384 } 380 385 }; 381 386 382 - const toStandardSchema = <TSchema extends BaseSchema>( 383 - schema: TSchema, 384 - ): StandardSchemaV1.Props<InferInput<TSchema>, InferOutput<TSchema>> => { 387 + const toStandardSchema = <TSchema extends BaseSchema>(schema: TSchema): LexStandardSchema<TSchema> => { 385 388 return { 386 389 version: 1, 387 390 vendor: '@atcute/lexicons',