Skip to content

Instantly share code, notes, and snippets.

View willmtemple's full-sized avatar

Will Temple willmtemple

View GitHub Profile
@willmtemple
willmtemple / templates-microsoft.txt
Last active November 1, 2023 17:20
Current TypeSpec Templates
packages/http/lib/auth.tsp
89:model ApiKeyAuth<TLocation extends ApiKeyLocation, TName extends string> {
packages/http/lib/http.tsp
15:model Response<Status> {
30:model Body<T> {
103:model PlainData<T> {
packages/json-schema/lib/main.tsp
158:model Json<T> {
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID8w+xPMnOAtzmVZKymO080hHnAl96rPv1TJ3z718bk1 wtemple@alto
/**
* Copyright (c) Will Temple 2022
*
* # ELEMENTAL TYPE SYSTEM
*
* This module describes an elemental type system composed of only five
* fundamental type forms that I find to be highly expressive in simply-typed
* contexts.
*
* By simply-typed, I mean systems that do not include type-binding.
@willmtemple
willmtemple / example.ts
Created October 6, 2022 16:19
Type-space OData stuff
interface Foo {
a: string;
b: number;
bar: Bar;
}
interface Bar {
a: number;
b: string;
baz: Baz;
@willmtemple
willmtemple / index.ts
Created May 9, 2022 17:57
Old-style Inheritance
declare class Vehicle {
engines: number;
ignition(): void;
drive(): void;
}
declare class Car extends Vehicle {
wheels: number;
}
@willmtemple
willmtemple / stages_of_rush.json
Last active February 3, 2021 20:34
Stages of Rush
{
"scripts": {
"rush:denial": "rushx clean && rushx build",
"rush:anger": "rush clean && rush rebuild",
"rush:bargaining": "rush clean && rush purge && rush update --full && rush rebuild",
"rush:depression": "while true; do rm -rf common/temp && npm run rush:bargaining; done",
"rush:acceptance": "cd ..; rm -rf azure-sdk-for-js; git clone https://github.com/azure/azure-sdk-for-js.git"
}
}
@willmtemple
willmtemple / lib.rs
Last active July 22, 2020 18:57
RSX - HTML in Rust
mod utils;
use wasm_bindgen::prelude::*;
mod vdom;
use vdom::*;
mod dom;
use dom::mount;
@willmtemple
willmtemple / index.ts
Last active June 29, 2020 18:16
magic typescript function that returns its arguments' AST
// This uses my modified version of typescript from my branch github.com/willmtemple/typescript#alchemy
import * as ts from "typescript/built/local/typescript";
import * as fs from "fs";
import * as os from "os";
import { promisify } from "util";
const readFile = promisify(fs.readFile);
@willmtemple
willmtemple / ultimateMatcher.ts
Last active February 25, 2020 03:31
ultimateMatcher.ts
declare export function match<
DiscriminatedUnion extends { [K in Discriminator]: string | number },
Pattern extends Partial<
{
[K in DiscriminatedUnion[Discriminator]]: (
v: Extract<DiscriminatedUnion, { kind: K }>
) => any;
}
>,
Discriminator extends string | number = "kind"
interface DemoEnumPatternMap<T> {
Foo: (foo: Foo) => T,
Bar: (bar: Bar) => T
}
function matchDemoEnum<T>(value: DemoEnum, pattern: DemoEnumPatternMap<T>) : T {
switch (value.kind) {
case "Foo":
return pattern.Foo(value);
case "Bar":