Accept governance.ts beside governance.yml, folded by the typescript-as-data reference (#32) - #33
Merged
Conversation
…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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #32. Mirror of INTENTIUS/typescript-as-data#83.
--config <file>.ts: folded by@intentius/tsad-reference(default),--config-mode runto import instead,--config-mode checkfor both with a refusal on disagreement.import type { GovernanceConfig } from "@intentius/forgejo-warden") viadist/types; a library entrydist/index.jswith the loader; both bundles keep the reference external.examples/governance.{ts,yml,helpers.ts,not-data.ts}andsrc/config/load.test.ts.Blocked on the npm publish of
@intentius/tsad-reference1.1.0:package.jsonnames it, the lockfile does not yet, sonpm cion 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 defaultdoes 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.