Skip to content

Generate and version TypeScript declarations from _data API metadata#14

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/generate-typescript-declaration-files
Draft

Generate and version TypeScript declarations from _data API metadata#14
Copilot wants to merge 4 commits into
mainfrom
copilot/generate-typescript-declaration-files

Conversation

Copilot AI commented Jun 15, 2026

Copy link
Copy Markdown

This PR adds a deterministic path from GreyHack API JSON metadata to consumable TypeScript declarations for editor autocomplete and type-checking. It generates structured .d.ts interfaces (including method params, optionality, return unions, and docs) directly from the existing _data source of truth.

  • Generator implementation

    • Added generate_types.py to parse:
      • _data/functions.json (type → methods)
      • _data/arguments.json (method params)
      • _data/returns.json (method return variants)
      • _data/descriptions.json (JSDoc text)
    • Emits types/greyscript.d.ts under declare namespace GreyHack.
  • Generated API surface

    • Produces one interface per API type (including General).
    • Preserves method names from source data.
    • Maps optional args and subtype metadata (e.g., list subtypes) into TS signatures.
    • Includes JSDoc for methods where descriptions exist.
  • Type-quality adjustments in generation

    • Added targeted return-type overrides for known data inconsistencies:
      • CTFEvent.player_success(): boolean
      • General.str(...): string
    • Normalizes known doc typos during JSDoc emission to keep generated output clean.
  • Repository updates

    • Added /types/greyscript.d.ts (generated artifact).
    • Updated README.md with regeneration usage.
    • Added .gitignore entries for Python cache artifacts.
# regenerate declarations
python generate_types.py
# writes: types/greyscript.d.ts

Copilot AI changed the title [WIP] Generate TypeScript declaration files from JSON data Generate and version TypeScript declarations from _data API metadata Jun 15, 2026
Copilot AI requested a review from WyattSL June 15, 2026 01:50
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.

2 participants