-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: string defaults, chained index access, format subscope (#1024)
- Loading branch information
1 parent
1aa6064
commit 5284b60
Showing
104 changed files
with
2,603 additions
and
1,047 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@arktype/schema": patch | ||
--- | ||
|
||
### Add support for index access, less indeterminate morph union errors (see full release notes in [ArkType's CHANGELOG](../type/CHANGELOG.md)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@arktype/attest": patch | ||
--- | ||
|
||
### Add .satisfies as an attest assertion to compare the value to an ArkType definition. | ||
|
||
```ts | ||
attest({ foo: "bar" }).satisfies({ foo: "string" }) | ||
|
||
// Error: foo must be a number (was string) | ||
attest({ foo: "bar" }).satisfies({ foo: "number" }) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { attest } from "../assert/attest.js" | ||
import { contextualize } from "../utils.js" | ||
|
||
contextualize(() => { | ||
it("can assert types", () => { | ||
attest({ foo: "bar" }).satisfies({ foo: "string" }) | ||
|
||
attest(() => { | ||
attest({ foo: "bar" }).satisfies({ foo: "number" }) | ||
}).throws("foo must be a number (was string)") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { type } from "arktype" | ||
import { fromHere } from "@arktype/fs" | ||
|
||
console.log( | ||
"⏱️ Checking for V8 fast properties (https://v8.dev/blog/fast-properties) on Type...\n" | ||
) | ||
|
||
const t = type({ | ||
a: "string", | ||
b: "number" | ||
}) | ||
|
||
let hasFastProperties | ||
|
||
try { | ||
hasFastProperties = eval("%HasFastProperties(t)") | ||
} catch { | ||
throw new Error(`This test must be run in a V8-based runtime with the --allow-natives-syntax flag, e.g.: | ||
node --allow-natives-syntax ${fromHere()}`) | ||
} | ||
|
||
if (!hasFastProperties) { | ||
throw new Error("⚠️ Type instance has been deoptimized.") | ||
} | ||
|
||
console.log("🏎️ Type instance has fast properties!") |
Oops, something went wrong.