Skip to content

Instantly share code, notes, and snippets.

@wycats
wycats / 1-decorator.md
Last active April 13, 2024 17:25
Thoughts on readonly accessor decorators in TypeScript

Getter-Only Auto-Accessor Decorators

Broadly speaking, the idea is that you should be able to create an accessor decorator that doesn't expose a setter.

I think the most natural way to express this is for the set function returned by an accessor decorator to have a never return type. The idea is that such a decorator would result in the type system treating the resulting field as if it was a manually written getter without a setter.

Here's an example scenario:

import { Friend } from "hypothetical-lib";
import { CachedFormula, Cell, Formula } from "@starbeam-lite/core";
import { EventRecorder, TestScheduler } from "@workspace/test-utils";
import { describe, expect, it } from "vitest";
import { subscribe } from "../src/subtle";
import { TAG } from "@starbeam-lite/shared";
describe("subscribe", () => {
describe("equivalent to Signal.subtle.Watcher (ported tests)", () => {
it("should work", () => {
const events = new EventRecorder();

Ember's new GJS syntax is now supported by GitHub!

GJS

A boring component:

class ActionButton extends Component {
  <template>
 

Factories

A factory is a function that returns a new reactive object.

  • Reactive Factories return reactive objects.
  • Resource Factories also return reactive objects, but they also register cleanup functions that are called when the object is no longer needed.

You can use a class as a factory, but it's not required. When you use a class as a factory, its constructor must take zero required arguments.

@wycats
wycats / spec.md
Created April 25, 2023 15:26
A "Spec" for Starbeam renderers. It's just really initial thoughts and isn't structured super-well yet.

Starbeam Renderers

Framework Renderer Status Spec Compatibility
React released next release
Preact released next release
Vue next release next release
Svelte designing -
Ember designing -
Solid roadmap -
{
"public": true
}

October 25, 2022 to November 4, 2022

Generics around missingness

function Name<S extends string | undefined>(name: S): S {
  return name;
}

Making unique-id a importable function

The Use Cases

import { uniqueId } from "@ember/???";

<template>
  {{#let (unique-id) as |id|}}

I'm assuming these are all talking about cases that didn't already have semis:

Top-Level TemplateDeclaration

<template>
  Hello
</template>|
//         ^ 🚫

Proposal for Improving Mass Assignment

For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.

Sign Allowed Fields

When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.

To allow new known fields to be added via JS, we could add: