Add Script.declareVersion() and emit Versions type map from versioned generated code#1932
Draft
Add Script.declareVersion() and emit Versions type map from versioned generated code#1932
Script.declareVersion() and emit Versions type map from versioned generated code#1932Conversation
| }); | ||
|
|
||
| it("declares versioned code grouped by name and coder version", 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
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
pmcelhaney
requested changes
Apr 22, 2026
| version?: string; | ||
| } | ||
| ).version ?? ""; | ||
|
|
Collaborator
There was a problem hiding this comment.
The version property is now part of coder so this check can be removed.
Contributor
Author
There was a problem hiding this comment.
Updated in 080fd02: declareVersion now uses coder.version directly and removes the optional cast/check.
| isDefault: false, | ||
| isType: true, | ||
| jsdoc: "", | ||
| typeDeclaration: coder.typeDeclaration(this.exports, this), |
Collaborator
There was a problem hiding this comment.
This typeDeclaration piece doesn't belong.
Contributor
Author
There was a problem hiding this comment.
Addressed in 080fd02: removed the typeDeclaration usage from version declarations, so Versions entries now come from the generated code only.
Copilot
AI
changed the title
Add
Add Apr 22, 2026
Script.declareVersion() and emit Versions type map in generated script contentsScript.declareVersion() and emit Versions type map from versioned generated code
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.Follow-up review feedback is incorporated:
declareVersionnow readscoder.versiondirectly (no optional version cast/check).Versionsentries are derived from generated version code only (notypeDeclarationfallback).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
Add a new method to the Script class, declareVersion(coder, name).
It should work like export, adding some code to an internal Map called versions.
The key of the versions Map 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 named Versions whose 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.Versionsvalues are emitted from the declared version code (not fromtypeDeclaration).Tasks
versionsstate toScriptand implementeddeclareVersion(coder, name).isInProgress,finished).versionsTypeStatements()and injectedVersionsemission intocontents().test/typescript-generator/script.test.tsfor version grouping andcontents()output.coder.versiondirectly and removetypeDeclarationusage from version declaration output.