Reduced type shapes from a schema library, used to develop and measure microsoft/TypeScript#64172.
A schema library expresses a self-referential schema with a getter:
const node = object({
name: text(),
get children() {Reduced type shapes from a schema library, used to develop and measure microsoft/TypeScript#64172.
A schema library expresses a self-referential schema with a getter:
const node = object({
name: text(),
get children() {| git config --global url."git@github.com:".insteadof "https://github.com/" |
asdf
| import * as z from "zod"; | |
| export const a = z.object({ | |
| a: z.string(), | |
| b: z.string(), | |
| c: z.string(), | |
| }); | |
| export const b = a.omit({ | |
| a: true, |
| import { randomString } from "./benchUtil.js"; | |
| import { metabench } from "./metabench.js"; | |
| export function lazyWithInternalProp<T>(getter: () => T) { | |
| return { | |
| __value: undefined as T, | |
| get value() { | |
| if (this.__value) return this.__value; | |
| const value = getter(); | |
| this.__value = value; |
| function lazy<T>(getter: () => T): { value: T } { | |
| return { | |
| get value() { | |
| const value = getter(); | |
| Object.defineProperty(this, "value", { value }); | |
| return value; | |
| }, | |
| }; | |
| } |
| import * as z from "zod"; | |
| const mySchema = z.string(); | |
| // there is a global schema registry | |
| z.globalRegistry; // => ZodRegistry<unknown, z.ZodType> | |
| // add schema to registry w/ associated metadata | |
| z.globalRegistry.add(mySchema, { name: "foo", description: "bar" }); | |
| // equivalent convenience method (returns mySchema) |
| alias howto="gh copilot suggest -t shell" |
| [ | |
| { | |
| "key": "cmd+;", | |
| "command": "editor.action.goToDeclaration" | |
| }, | |
| { | |
| "key": "shift+cmd+;", | |
| "command": "workbench.action.navigateBack", | |
| "when": "canNavigateBack" | |
| } |
| gh repo clone https://github.com/colinhacks/live-typescript-monorepo | |
| cd live-typescript-monorepo | |
| cd project-references | |
| pnpm i | |
| code . | |
| # open packages/pkg-b/index.ts | |
| # see Cannot find module 'pkg-a' or its corresponding type declarations | |
| pnpm build # runs `tsc -b` | |
| # restart ts server, "Cannot find module" goes away | |
| pnpm clean # deletes node_modules in all packages |