Refactor TypeScript writer into modular file structure#82
Merged
Conversation
Collaborator
ryukzak
commented
Feb 27, 2026
- Split the 1651-line typescript.ts monolith into a typescript/ directory with 4 focused modules:
- name.ts (124 lines) — all naming functions (module names, file names, field names, profile class names, method names)
- utils.ts (90 lines) — type resolution helpers (primitive types, enum types, field type resolution)
- profile.ts (1055 lines) — profile generation logic (profile classes, imports, overrides, slices, extensions)
- writer.ts (317 lines) — TypeScript class with core generation methods
- Removed 3 unused functions (generateProfileType, generateAttachProfile, generateExtractProfile)
- Reduced export surface: internal-only symbols are no longer exported
- Renamed functions for consistency: canonicalToName → tsNameFromCanonical, safeCamelCase → tsCamelCase, tsFhirPackageDir → tsPackageDir, Fallback → tsQualifiedMethodName
Split writer.ts (1651 lines) into three files: - utils.ts: standalone utility functions and constants - profile.ts: profile-specific helpers and extracted class methods - writer.ts: TypeScript class with non-profile methods (317 lines)
Move all name-generation functions (module names, file names, field names, profile class names, method names, etc.) from utils.ts and profile.ts into a dedicated name.ts file.
- Make internal-only symbols non-exported in name.ts, utils.ts, profile.ts - Remove unused generateProfileType, generateAttachProfile, generateExtractProfile functions (dead code)
- tsExtensionMethodFallback → tsQualifiedExtensionMethodName - tsSliceMethodFallback → tsQualifiedSliceMethodName
- canonicalToName → tsNameFromCanonical - safeCamelCase → tsCamelCase - tsFhirPackageDir → tsPackageDir
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.