-
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