-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
TypeSpec-Go Emitter - Project Structure and Architecture Discussion
π― Executive Summary
This issue defines the comprehensive project architecture for the TypeSpec-Go emitter, based on the complete emitter specification in doc/emitter.md. We need to establish a modern, scalable foundation using Mise task runner and TypeSpec emitter patterns.
π Current State
- β
Complete specification exists (
doc/emitter.md) - β Basic project structure (README, LICENSE, .gitignore)
- β Zero implementation - greenfield project
- β No development environment setup
- β No build system or testing framework
ποΈ Proposed Architecture
Option 1: Standard TypeSpec Emitter + Mise (RECOMMENDED)
typespec-go/
βββ src/
β βββ index.ts # Main exports
β βββ emitter.ts # Core $onEmit function
β βββ options.ts # Configuration interface
β βββ lib.ts # Utility functions
β βββ generators/
β β βββ models.ts # Model/struct generation
β β βββ enums.ts # Enum generation
β β βββ unions.ts # Union/sealed interface
β β βββ operations.ts # Service interface generation
β β βββ utils.ts # Helper functions
β βββ decorators/
β β βββ go-decorators.ts # Go-specific decorators
β βββ types/
β βββ go-types.ts # Type definitions
βββ tests/
β βββ basic.test.ts
β βββ models.test.ts
β βββ enums.test.ts
β βββ fixtures/
β βββ petstore/
β β βββ main.tsp
β βββ generated/ # Test output
βββ mise-tasks/ # Executable task scripts
β βββ build
β βββ test
β βββ lint
β βββ dev
βββ mise.toml # Mise configuration
βββ package.json # npm dependencies only
βββ tsconfig.json
βββ README.md
Why This Architecture Wins:
- TypeSpec Compliance - Follows official emitter patterns exactly
- Mise-Driven - Modern task management, no npm scripts
- Scalable - Clear separation of concerns
- Maintainable - Easy to extend and test
- Professional - Uses industry best practices
π§ Key Technology Decisions
Mise Task Runner
- β Replaces package.json scripts entirely
- β Task dependencies and conditional execution
- β Environment management and tool versioning
- β Source-based builds (only rebuild when needed)
- β Monorepo-ready for future scaling
TypeScript/Node.js Emitter
- β Official TypeSpec emitter patterns
- β AssetEmitter architecture
- β ESM modules and modern toolchain
- β Comprehensive testing with Vitest
Package Structure
# mise.toml
min_version = "2025.11.2"
[env]
NODE_ENV = "{{ env.NODE_ENV | default(value='development') }}"
PROJECT_NAME = "{{ config_root | basename }}"
[tools]
node = "lts"
typescript = "latest"
"npm:@typespec/compiler" = "latest"
"npm:@typespec/emitter-framework" = "latest"
"npm:vitest" = "latest"
"npm:eslint" = "latest"
"npm:prettier" = "latest"
[tasks.build]
description = "Build TypeScript to dist/"
sources = ["src/**/*.ts"]
outputs = ["dist/**"]
run = "tsc"
[tasks.test]
description = "Run test suite"
depends = ["build"]
run = "vitest run"
[tasks.lint]
description = "Run ESLint"
run = "eslint src/ test/ --max-warnings=0"
[tasks.dev]
description = "Development with watch mode"
run = "tsc --watch"π Implementation Phases
Phase 1: Foundation (Critical Path)
- Initialize project with Mise and TypeScript
- Create basic emitter skeleton extending AssetEmitter
- Set up testing framework with TypeSpec integration
- Implement namespace-to-package mapping
- Basic model generation (struct generation)
Phase 2: Core Features (High Impact)
- Enum generation (string + iota strategies)
- Union generation (sealed interface pattern)
- Operation/service generation
- Go-specific decorators (@go.name, @go.package)
- Comprehensive testing with real examples
Phase 3: Advanced Features (Professional Polish)
- HTTP handler generation
- Validation logic (@minlength, @maxlength, etc.)
- Advanced TypeSpec features (template models, composition)
- Performance optimization and benchmarks
- Documentation and examples
π― Immediate Action Items
Priority 1: Project Setup
- Create
mise.tomlwith tasks and tool configuration - Initialize
package.jsonwith TypeSpec dependencies - Set up TypeScript configuration
- Create basic emitter skeleton
- Set up testing framework
Priority 2: Core Implementation
- Implement namespace-to-package mapping
- Create model struct generation
- Add enum generation logic
- Create union/sealed interface generation
- Add basic operation support
Priority 3: Advanced Features
- Implement Go-specific decorators
- Add HTTP handler generation
- Create comprehensive test suite
- Add performance benchmarks
- Create documentation and examples
π€ Open Questions
Critical Blocker:
What is the exact TypeSpec emitter development pattern?
We need to understand:
- How to extend
@typespec/compilerwith emitter classes- Standard project structure for TypeSpec emitters
- Integration with TypeSpec CLI (
tsp compile)- Core TypeScript dependencies and development patterns
Architecture Questions:
- Monorepo vs single package? - Start single, scale to monorepo later?
- Testing strategy? - How to integrate TypeSpec compilation in tests?
- Performance considerations? - Large TypeSpec files, memory usage?
- Error handling? - Diagnostic reporting, user experience?
π Success Criteria
MVP Success:
- β Compiles basic TypeSpec to Go models/enums
- β Integrates with TypeSpec CLI
- β Has comprehensive test coverage
- β Follows emitter specification exactly
Production Success:
- β Handles complex TypeSpec features (unions, operations, decorators)
- β Generates production-ready Go code
- β Has real-world examples and documentation
- β Performance suitable for large projects
π References
- Complete Specification:
doc/emitter.md - TypeSpec Documentation: https://typespec.io
- Mise Documentation: https://mise.jdx.dev
- Discord Discussion: Archive of TypeSpec-Go emitter planning
π·οΈ Labels
architectureproject-structuremisetypescripttypespecfoundationgood-first-issue
π― Call to Action
This issue is ready for immediate implementation. We have:
- β Complete specification to follow
- β Clear architecture defined
- β Modern tooling selected
- β Implementation phases outlined
Next Steps:
- Approve this architecture π/π
- Resolve the TypeSpec emitter pattern question
- Begin Phase 1 implementation
Ready to build the best TypeSpec-Go emitter in the ecosystem! π
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request