Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
Schema: fix DocAnnotations definition (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti authored Dec 13, 2023
1 parent d39ce40 commit 5da1d36
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-jars-hide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect/schema": patch
---

Schema: fix `DocAnnotations` definition
12 changes: 6 additions & 6 deletions docs/modules/Schema.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ Schema<A> + B -> Schema<A & Brand<B>>
```ts
export declare const brand: <B extends string | symbol, A>(
brand: B,
options?: DocAnnotations<A> | undefined
options?: DocAnnotations
) => <I>(self: Schema<I, A>) => BrandSchema<I, A & Brand.Brand<B>>
```
Expand Down Expand Up @@ -4216,14 +4216,13 @@ Added in v1.0.0
**Signature**

```ts
export interface DocAnnotations<A> extends AST.Annotations {
export interface DocAnnotations extends AST.Annotations {
readonly identifier?: AST.IdentifierAnnotation
readonly title?: AST.TitleAnnotation
readonly description?: AST.DescriptionAnnotation
readonly examples?: AST.ExamplesAnnotation
readonly default?: AST.DefaultAnnotation
readonly documentation?: AST.DocumentationAnnotation
readonly message?: AST.MessageAnnotation<A>
}
```

Expand All @@ -4234,7 +4233,8 @@ Added in v1.0.0
**Signature**

```ts
export interface FilterAnnotations<A> extends DocAnnotations<A> {
export interface FilterAnnotations<A> extends DocAnnotations {
readonly message?: AST.MessageAnnotation<A>
readonly typeId?: AST.TypeAnnotation | { id: AST.TypeAnnotation; params: unknown }
/**
* Attaches a JSON Schema annotation to this refinement.
Expand Down Expand Up @@ -4460,7 +4460,7 @@ Added in v1.0.0
```ts
export declare const optional: <I, A>(
schema: Schema<I, A>,
options?: DocAnnotations<A> | undefined
options?: DocAnnotations
) => OptionalPropertySignature<I, true, A, true>
```

Expand All @@ -4473,7 +4473,7 @@ Added in v1.0.0
```ts
export declare const propertySignature: <I, A>(
schema: Schema<I, A>,
options: DocAnnotations<A>
options: DocAnnotations
) => PropertySignature<I, false, A, false>
```

Expand Down
16 changes: 8 additions & 8 deletions src/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ export class PropertySignatureImpl<From, FromIsOptional, To, ToIsOptional> {
*/
export const propertySignature = <I, A>(
schema: Schema<I, A>,
options: DocAnnotations<A>
options: DocAnnotations
): PropertySignature<I, false, A, false> =>
new PropertySignatureImpl({
_tag: "PropertySignature",
Expand All @@ -732,7 +732,7 @@ export const propertySignature = <I, A>(
*/
export const optional = <I, A>(
schema: Schema<I, A>,
options?: DocAnnotations<A>
options?: DocAnnotations
): OptionalPropertySignature<I, true, A, true> =>
new PropertySignatureImpl({
_tag: "Optional",
Expand Down Expand Up @@ -939,10 +939,10 @@ export interface BrandSchema<From, To extends Brand.Brand<any>>
extends Schema<From, To>, Brand.Brand.Constructor<To>
{}

const appendBrandAnnotation = <B extends string | symbol, A>(
const appendBrandAnnotation = <B extends string | symbol>(
ast: AST.AST,
brand: B,
options?: DocAnnotations<A>
options?: DocAnnotations
): AST.AST => {
if (AST.isTransform(ast)) {
return AST.createTransform(
Expand Down Expand Up @@ -978,7 +978,7 @@ const appendBrandAnnotation = <B extends string | symbol, A>(
*/
export const brand = <B extends string | symbol, A>(
brand: B,
options?: DocAnnotations<A>
options?: DocAnnotations
) =>
<I>(self: Schema<I, A>): BrandSchema<I, A & Brand.Brand<B>> => {
const ast = appendBrandAnnotation(self.ast, brand, options)
Expand Down Expand Up @@ -1481,20 +1481,20 @@ const toAnnotations = <A>(
/**
* @since 1.0.0
*/
export interface DocAnnotations<A> extends AST.Annotations {
export interface DocAnnotations extends AST.Annotations {
readonly identifier?: AST.IdentifierAnnotation
readonly title?: AST.TitleAnnotation
readonly description?: AST.DescriptionAnnotation
readonly examples?: AST.ExamplesAnnotation
readonly default?: AST.DefaultAnnotation
readonly documentation?: AST.DocumentationAnnotation
readonly message?: AST.MessageAnnotation<A>
}

/**
* @since 1.0.0
*/
export interface FilterAnnotations<A> extends DocAnnotations<A> {
export interface FilterAnnotations<A> extends DocAnnotations {
readonly message?: AST.MessageAnnotation<A>
readonly typeId?: AST.TypeAnnotation | { id: AST.TypeAnnotation; params: unknown }
/**
* Attaches a JSON Schema annotation to this refinement.
Expand Down

0 comments on commit 5da1d36

Please sign in to comment.