Add Script.declareVersion() and emit Versions type map in generated script contents#1932
Draft
Add Script.declareVersion() and emit Versions type map in generated script contents#1932
Script.declareVersion() and emit Versions type map in generated script contents#1932Conversation
| }); | ||
|
|
||
| it("declares versioned code grouped by name and coder version", async () => { | ||
| const repository = new Repository("/base/path"); |
| }); | ||
|
|
||
| it("outputs the contents including Versions when versions are declared", async () => { | ||
| const repository = new Repository("/base/path"); |
Copilot
AI
changed the title
[WIP] Add declareVersion method to Script class
Add Apr 18, 2026
Script.declareVersion() and emit Versions type map in generated script contents
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.
Summary
Adds
Script.declareVersion(coder, name)to register versioned type output by name/version and extendscontents()to emit aVersionstype alias representing that nested map. This enables version-aware type declarations to be generated alongside existing script exports.Version registry in
Scriptversions: Map<string, Map<string, ExportStatement>>.declareVersion(coder, name)with duplicate protection per(name, version)key.Version declarations included in generation lifecycle
isInProgress()/finished()to track version declaration promises.contents()awaits completion before formatting.Versionstype emissionversionsTypeStatements()and integrated it intocontents()output.Original Prompt
Issue:
script.declareVersion()Add a new method to the
Scriptclass,declareVersion(coder, name).It should work like
export, adding some code to an internal Map calledversions.The key of the
versionsMap will be a string corresponding to the name. The value will be another Map with a key of version (taken from the coder) and value of the code generated by the coder.The
contents()method will declare a type namedVersionswhose value is the map of maps of types.Manual acceptance tests
nameand differentcoder.versionvalues emits both entries under that name inVersions.contents()afterdeclareVersion(...)includes anexport type Versions = ...declaration in generated output.(name, version)pair does not create duplicate version entries.Tasks
versionsstate toScriptand implementeddeclareVersion(coder, name).isInProgress,finished).versionsTypeStatements()and injectedVersionsemission intocontents().test/typescript-generator/script.test.tsfor version grouping andcontents()output.