Skip to content

Accept governance.ts beside governance.yml, folded by the typescript-as-data reference (#32) - #33

Merged
lex00 merged 4 commits into
mainfrom
governance-ts
Sep 12, 2026
Merged

Accept governance.ts beside governance.yml, folded by the typescript-as-data reference (#32)#33
lex00 merged 4 commits into
mainfrom
governance-ts

Conversation

@lex00

@lex00 lex00 commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Closes #32. Mirror of INTENTIUS/typescript-as-data#83.

  • --config <file>.ts: folded by @intentius/tsad-reference (default), --config-mode run to import instead, --config-mode check for both with a refusal on disagreement.
  • Types exported (import type { GovernanceConfig } from "@intentius/forgejo-warden") via dist/types; a library entry dist/index.js with the loader; both bundles keep the reference external.
  • examples/governance.{ts,yml,helpers.ts,not-data.ts} and src/config/load.test.ts.

Blocked on the npm publish of @intentius/tsad-reference 1.1.0: package.json names it, the lockfile does not yet, so npm ci on this branch fails until the package exists. Tested locally against the packed 1.1.0 tarballs (113 tests green, build green, the built loader runs check mode on the example).

Two subset limits surfaced writing the example, filed against the spec: export default does not fold (F-Scan), and a same-file arrow helper called as a value does not fold. The example uses a named export and a sibling-file helper, which do.

…as-data reference (#32)

A .ts policy is an object literal typed by GovernanceConfig, exported as
`policy`. By default it is folded to its value by @intentius/tsad-reference
without being run (--config-mode fold); run mode imports it instead; check
mode does both and refuses a file on which they differ. The loader
normalises through JSON so an undefined property is absent on either path,
which is what selective-by-omission reads.

The package now exports its policy types (dist/types via tsc) and the
loader from a library entry (dist/index.js), and both bundles mark the
reference external so its TypeScript dependency is not bundled.

examples/governance.{ts,yml} are the same policy twice, asserted equal in
src/config/load.test.ts, with helpers.ts for the shared parts and
not-data.ts for the file fold refuses and run accepts.

Two limits of the subset surfaced writing the example and are filed in
the spec repository: a default export does not fold (F-Scan), and a
same-file arrow-function helper called as a value does not fold; a
helper in a sibling file does.
…der the data-host profile of spec 1.2

The two limits the first example worked around are gone: spec 1.2 admits
export default in the data-host profile (S-ExportDefault) and binds a
same-file arrow helper as a project-local function (S-LocalFunction). The
loader folds under that profile now, the example is the file anyone would
write first, and helpers.ts is no longer needed.
…that names it

The package is published, so npm ci works on this branch; the lockfile
carries the real resolution rather than a packed tarball.
# Conflicts:
#	package-lock.json
#	package.json
@lex00
lex00 merged commit 977f7ca into main Sep 12, 2026
5 checks passed
@lex00
lex00 deleted the governance-ts branch September 12, 2026 19:11
lex00 added a commit that referenced this pull request Sep 12, 2026
…) and define __filename in the ESM bundles (#35)

The merge of main into #33 kept main's package.json and re-added only the
dependency, so the merged build script bundled @intentius/tsad-reference
and, through it, typescript into cli.js, and the library entry and its
types were never built. typescript reads __filename at load, which an ES
module does not have, so every --config-mode that folds died with
"__filename is not defined" while the tests, which run the sources,
stayed green; the typescript-as-data tutorial job caught it.

Back to #33's build: the reference external in both bundles, chant
external in the library one, dist/index.js and dist/types built, exports
and types fields. The banner also defines __filename and __dirname from
import.meta.url beside the require it already defined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Accept governance.ts, evaluated by the typescript-as-data reference, beside governance.yml

1 participant