Skip to content

Commit

Permalink
finish initial landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
ssalbdivad committed May 29, 2024
1 parent 39964a4 commit b2a42a8
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ark/dark/injected.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"repository": {
"arkDefinition": {
"contentName": "meta.embedded.arktype.definition",
"begin": "(([^\\)\\(\\s]+)?(?:type|scope|define|match|fn|\\.morph|\\.and|\\.or|\\.when))(\\()",
"begin": "(([^\\)\\(\\s]+)?(?:type|scope|define|match|fn|\\.morph|\\.and|\\.or|\\.when|\\.extends|\\.intersect))(\\()",
"beginCaptures": {
"1": {
"name": "entity.name.function.ts"
Expand Down
2 changes: 1 addition & 1 deletion ark/dark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "arkdark",
"displayName": "ArkDark",
"description": "ArkType syntax highlighting and theme⛵",
"version": "5.1.6",
"version": "5.1.7",
"publisher": "arktypeio",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion ark/dark/tsWithArkType.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"repository": {
"arkDefinition": {
"contentName": "meta.embedded.arktype.definition",
"begin": "(([^\\)\\(\\s]+)?(?:type|scope|define|match|fn|\\.morph|\\.and|\\.or|\\.when))(\\()",
"begin": "(([^\\)\\(\\s]+)?(?:type|scope|define|match|fn|\\.morph|\\.and|\\.or|\\.when|\\.extends|\\.intersect))(\\()",
"beginCaptures": {
"1": {
"name": "entity.name.function.ts"
Expand Down
6 changes: 3 additions & 3 deletions ark/docs/src/content/docs/betterErrors.twoslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ if (out instanceof type.errors) {
`luckyNumbers[1] must be a bigint or a number (was string)
name must be a string (was missing)
isAdmin must be false, null or true (was 1)`
) {
)
throw new Error()
}

// ---cut-end---
// hover out.summary to see the validation error
// hover out.summary to see validation errors
console.error(out.summary)
} else console.log(out.luckyNumbers)
26 changes: 26 additions & 0 deletions ark/docs/src/content/docs/deepIntrospectability.twoslash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { type } from "arktype"

const user = type({
name: "string",
luckyNumbers: "(number | bigint)[]",
"isAdmin?": "boolean | null"
})

// ---cut---
user.extends("object") // true
user.extends("string") // false
// ---cut-start---
// prettier-ignore
// ---cut-end---
user.extends({ // true
luckyNumbers: "unknown[]",
})
// ---cut-start---
// prettier-ignore
// ---cut-end---
user.extends({ // false
luckyNumbers: "number[]"
})

// get transitively referenced TypeNodes
console.log(user.raw.references)
25 changes: 15 additions & 10 deletions ark/docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import { HeroBackdrop } from "../../components/HeroBackdrop.tsx"
import TsBlock from "../../components/TsBlock.astro"
import betterErrorsSrc from "./betterErrors.twoslash.ts?raw"
import clearAndConciseSrc from "./clearAndConcise.twoslash.ts?raw"
import deepIntrospectability from "./deepIntrospectability.twoslash.ts?raw"
import intrinsicOptimization from "./intrinsicOptimization.twoslash.ts?raw"
import unparalleledDxSrc from "./unparalleledDx.twoslash.ts?raw"

<div class="not-content">
Expand All @@ -37,12 +39,13 @@ import unparalleledDxSrc from "./unparalleledDx.twoslash.ts?raw"

<CardGrid stagger>
<Card title="Unparalleled DX" icon="seti:tsconfig">
Type syntax you already know with safety unlike anything you've ever seen
Type syntax you already know with safety and completions unlike anything
you've ever seen
<TsBlock code={unparalleledDxSrc} />
</Card>
<Card title="Faster. Everywhere." icon="rocket">
100x faster than Zod with editor performance that will remind you how
autocomplete is supposed to feel
<Card title="Faster... everything" icon="rocket">
100x faster than Zod at runtime with editor performance that will remind you
how autocomplete is supposed to feel
<Tabs>
<TabItem label="Runtime">
<RuntimeBenchmarksGraph />
Expand All @@ -52,22 +55,24 @@ import unparalleledDxSrc from "./unparalleledDx.twoslash.ts?raw"
</TabItem>
</Tabs>
</Card>
<Card title="Clear and concise" icon="comment-alt">
<Card title="Clarity and Concision" icon="comment-alt">
Definitions are half as long, type errors are twice as readable, and hovers
tell you just what really matters
<TsBlock code={clearAndConciseSrc} />
</Card>
<Card title="Better errors" icon="error">
<Card title="Better Errors" icon="error">
Deeply customizable messages with great defaults
<TsBlock code={betterErrorsSrc} />
</Card>
<Card title="Deeply introspectable" icon="seti:code-search">
<Card title="Deep Introspectability" icon="seti:code-search">
ArkType uses set theory to understand and expose the relationships between
your types at runtime the way TypeScript does at compile time
<TsBlock code={deepIntrospectability} />
</Card>
<Card title="Smarter by default" icon="seti:smarty">
Every schema you define is internally optimized to provide the clearest,
fastest validation possible
<Card title="Intrinsic Optimization" icon="seti:smarty">
Every schema is internally normalized and reduced to its purest and fastest
representation
<TsBlock code={intrinsicOptimization} />
</Card>
{/* <Card title="Portable" icon="seti:json">
Most definitions are just objects and strings- take them across the stack or
Expand Down
15 changes: 15 additions & 0 deletions ark/docs/src/content/docs/intrinsicOptimization.twoslash.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { type } from "arktype"
// ---cut---
// all unions are optimally discriminated-
// even at nested paths or in multiple passes!
const account = type({
kind: "'admin'",
"powers?": "string[]"
})
.or({
kind: "'superadmin'",
"superpowers?": "string[]"
})
.or({
kind: "'pleb'"
})
3 changes: 2 additions & 1 deletion ark/type/__tests__/type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ contextualize(() => {
const result = t("invalid")
attest(result instanceof type.errors && result.throw())
} catch (e) {
attest(e instanceof type.errors).equals(true)
attest(e instanceof AggregateError).equals(true)
attest((e as AggregateError).errors instanceof type.errors)
return
}
throw new AssertionError({ message: "Expected to throw" })
Expand Down

0 comments on commit b2a42a8

Please sign in to comment.