Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add JSDoc for common Type methods #1157

Merged
merged 4 commits into from
Oct 4, 2024

Conversation

Dimava
Copy link
Contributor

@Dimava Dimava commented Oct 1, 2024

No description provided.

Copy link
Member

@ssalbdivad ssalbdivad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some general thoughts + updated descriptions.

ark/type/methods/base.ts Outdated Show resolved Hide resolved
ark/type/methods/base.ts Outdated Show resolved Hide resolved
ark/type/methods/base.ts Outdated Show resolved Hide resolved
ark/type/methods/base.ts Outdated Show resolved Hide resolved
ark/type/methods/base.ts Outdated Show resolved Hide resolved
or<const def, r = type.infer<def, $>>(
def: type.validate<def, $>
): instantiateType<t | r, $>

/**
* Narrow this type to its subtype.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a custom predicate to the Type.

array(): ArrayType<t[], $>

/**
* Morph this type with a chain of morphs.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't show the different syntax kinds. Just summarize how the chaining works, and explain that types can be morphed through other types which will apply validation and morphs from those types.

ark/type/type.ts Outdated
unit: UnitTypeParser<$>
/**
* Constructs a union of literals and by-reference objects
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a Type that is satisfied only by a value === to one of the arguments passed to this function.

ark/type/type.ts Outdated
@@ -96,7 +101,18 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
define: DefinitionParser<$>
generic: GenericParser<$>
schema: SchemaParser<$>
/**
* Construct a literal (or by-reference object) type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a Type that is satisfied only by a value === to the argument passed to this function.

@@ -42,12 +42,25 @@ import type { instantiateType } from "./instantiate.ts"
interface Type<out t = unknown, $ = {}>
extends Callable<(data: unknown) => distill.Out<t> | ArkErrors> {
[inferred]: t
/**
* Generic argument. May be used for type reconstruction.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The top-level generic parameter accepted by the Type. Potentially includes morphs and subtype constraints not reflected in the types fully-inferred input (via inferIn) or output (via infer or inferOut).

@ssalbdivad ssalbdivad changed the title feat: Add basic JSDoc for primary Type feat: add JSDoc for common Type methods Oct 4, 2024
@ssalbdivad ssalbdivad merged commit af48925 into arktypeio:main Oct 4, 2024
6 checks passed
@ssalbdivad
Copy link
Member

I'll tweak some of the examples a bit and publish in the next release 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done (merged or closed)
Development

Successfully merging this pull request may close these issues.

2 participants