Skip to content

Refactor TS and JS generators to share common field generation logic - #40

Merged
rijesha merged 4 commits into
mainfrom
copilot/increase-code-reuse-ts-js-gen
Nov 29, 2025
Merged

Refactor TS and JS generators to share common field generation logic#40
rijesha merged 4 commits into
mainfrom
copilot/increase-code-reuse-ts-js-gen

Conversation

Copilot AI commented Nov 29, 2025

Copy link
Copy Markdown
Contributor

ts_gen.py and js_gen.py had ~88 lines of duplicated field generation logic and identical type mappings.

Changes

  • New shared module ts_js_base.py:

    • common_types / common_typed_array_methods: Shared type dictionaries
    • BaseFieldGen.generate(): Parameterized field generation accepting type dicts
  • Refactored generators:

    • FieldTsGen and FieldJsGen now delegate to BaseFieldGen.generate()
    • Type mappings imported from shared module
# Before (duplicated in both files)
class FieldTsGen():
    @staticmethod
    def generate(field, packageName):
        # ~88 lines of logic
        ...

# After
class FieldTsGen():
    @staticmethod
    def generate(field, packageName):
        return BaseFieldGen.generate(
            field, packageName, ts_types, ts_typed_array_methods
        )

Generated output unchanged. All 74 tests pass.

Original prompt

This section details on the original issue you should resolve

<issue_title>Increase code reuse with ts and js gen </issue_title>
<issue_description></issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot Bot and others added 3 commits November 29, 2025 01:13
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
…via ts_js_base.py

Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Copilot Bot changed the title [WIP] Increase code reuse with TypeScript and JavaScript generation Refactor TS and JS generators to share common field generation logic Nov 29, 2025
Copilot Bot requested a review from rijesha November 29, 2025 01:21
@rijesha
rijesha marked this pull request as ready for review November 29, 2025 01:27
@rijesha
rijesha merged commit 56c065f into main Nov 29, 2025
@rijesha
rijesha deleted the copilot/increase-code-reuse-ts-js-gen branch December 6, 2025 03:20
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.

Increase code reuse with ts and js gen

2 participants