Skip to content

[Repo] Auto-generate packages/affine-{js,ts}/types.d.ts from compiler output #66

Description

@hyperpolymath

Problem

Two .d.ts files describe the public AffineScript API surface for downstream JS/TS consumers:

  • packages/affine-js/types.d.ts
  • packages/affine-ts/types.d.ts

They're hand-maintained today, which means:

  1. They're listed as "approved TypeScript exemptions" in .claude/CLAUDE.md, which is a policy solution to a technical problem.
  2. They drift from the actual compiler-emitted JS shape over time.
  3. Each new public type/function in canonical AffineScript needs a manual .d.ts update.

The fix moves the .d.ts files from "policy violation" to "build artefact" — generate them from the canonical compiler's IR or codegen pass, treat them as compiler output, drop the exemption.

Acceptance criteria

  • Compiler emits .d.ts for any module flagged for JS/TS export (mechanism TBD: annotation, file-scope, separate manifest).
  • packages/affine-js/types.d.ts and packages/affine-ts/types.d.ts are removed from the source tree and added to .gitignore if they're build outputs, or generated into dist/ and consumed from there.
  • CI rebuilds them on every change to the public API.
  • Drop the two types.d.ts rows from the TypeScript Exemptions table in .claude/CLAUDE.md.

Notes on scope

This isn't urgent — the hand-maintained files work today. But it's the cleanest way to retire the exemption permanently, and shares infrastructure with whatever Node-target codegen (#35) ends up emitting.

Origin

TS-elimination audit, 2026-05-02 (recommendation #10).

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions