Skip to content

Instantly share code, notes, and snippets.

import { createGraph } from "jsr:@deno/graph@0.74.4";
const g1 = await createGraph("jsr:@mizchi/tpl@0.0.3");
console.log("g1", g1);
const g2 = await createGraph("npm:zod@3.23.6");
console.log("g2", g2);
/**
g1 {

This is reply for moonbit author.

https://twitter.com/bobzhang1988/status/1784065637092089951


I have a slightly different opinion.

TypeScript was an ecosystem that combined a universal escape hatch called any with incremental typing. The community-based DefinitelyTyped provided an experience that, from a personal perspective, expanded the world of typing just by sleeping on it. This is an experience that Flow and ReScript did not provide. Unfortunately.

trait Serializer {
serialize(Self) -> Bytes
}
impl Serializer for Int with serialize(self) {
Bytes::from_array([
self.land(0xFF),
self.lsr(8).land(0xFF),
self.lsr(16).land(0xFF),
self.lsr(24).land(0xFF)
// gc impl
import { flush, js_string, setMemory, spectest } from "./js_string.ts";
const { instance: { exports } } = await WebAssembly.instantiateStreaming(
fetch(new URL("../target/wasm-gc/release/build/main/main.wasm", import.meta.url)),
{
js_string,
spectest,
js: {
setTimeout, clearTimeout,

setTimeout binding

deno runner

import { flush, js_string, setMemory, spectest } from "../.mooncakes/mizchi/js_io/mod.ts";

type Instance = {
  fire: (fid: number) => void;
};
pub trait ToJson {
write_json_string(Self, Buffer) -> Unit
}
fn ToJson::write_json_string(self : Int, buf : Buffer) -> Unit {
buf.write_string(self.to_string())
}
fn ToJson::write_json_string(self : Bool, buf : Buffer) -> Unit {
buf.write_string(self.to_string())

String JS <=> Moonbit

struct MyCtx {
  result: String
  mut cur: Int
  input: @vec.Vec[Int]
}

pub fn app() -> MyCtx {
/*
analyze reserved properties from bundled dts for terser
$ pnpm tsm analyze.ts src/*.{ts, tsx} -i src/index.ts
{
"reservedProperties": [
"result",
"value",
"pubTypeKey",
"ikey",