Skip to content

Instantly share code, notes, and snippets.

View colinhacks's full-sized avatar

Colin McDonnell colinhacks

View GitHub Profile
@colinhacks
colinhacks / README.md
Created September 7, 2026 17:52
Recursive getter inference probe corpus — microsoft/TypeScript#64172

Recursive getter inference — probe corpus

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() {
@colinhacks
colinhacks / cmd.sh
Created December 13, 2025 17:48
no-http-clones
git config --global url."git@github.com:".insteadof "https://github.com/"
@colinhacks
colinhacks / scratch.md
Created July 2, 2025 22:49
scratch.md

asdf

@colinhacks
colinhacks / index.ts
Last active April 5, 2025 23:40
Chained `.extend()`
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;
@colinhacks
colinhacks / lazy-box.ts
Created December 5, 2024 21:50
Lazy box
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)
@colinhacks
colinhacks / .zshrc
Last active October 25, 2024 03:54
`howto` shell alias for recommending terminal commands
alias howto="gh copilot suggest -t shell"
@colinhacks
colinhacks / keybindings.json
Created August 12, 2024 20:25
`goToDefinition` and `navigateBack`
[
{
"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