Targets · TypeScript · Naming considerations

Naming considerations

A Program name nests to any depth — Ui.Button.Integer.Increment. This page is how that dotted name is carried into TypeScript, at both the value and the type level.

Contents

How a Program becomes TypeScript, in parts. Start with the introduction, then follow each part into the rendered output and the runtime it links against.

How it looks

Like JavaScript, the dotted name is kept exactly as written — and because TypeScript has real namespaces, the same path works as a type too.

const p: App.Profile = App.Profile /* … */;        // value and type, both dotted
Ui.Button.Integer.Increment(count, () => { … });   // verbatim

The natural idiom

Idiomatic TypeScript today leans on ES modules and named imports rather than namespace, which would discard the dotted shape. But TypeScript never removed namespaces, and they are exactly the right tool for mirroring Program's tree.

Keeping the real dotted name

Each namespace segment becomes a nested TypeScript namespace; the leaf is an export inside it. This gives a genuine dotted path at both levels: a function call and a type reference read the same as in Program, and the compiler resolves them natively.

namespace Ui {
  export namespace Button {
    export namespace Integer {
      export function Increment(count: ReactiveValue<number>, body: () => void): void { … }
    }
  }
}

// value: dotted, checked
Ui.Button.Integer.Increment(count, () => { … });
// type: also dotted
let s: App.Profile;

A built-in value type folds to a native annotation instead of a namespace — Maths.Integer is number, Text is string. A record TYPE you define is a class named by its dotted path.

Recommendation

Use nested namespaces directly. It is the one target where the dotted name survives at both the value and the type level with no compromise; the tradeoff is only that the output uses a feature some style guides discourage, which is a fair price for names that match the source exactly. The only identifiers ever rewritten are ordinary variables that collide with a reserved word.