refactor parseAppDir.ts and fix issue 197 #199
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.
Original (日本語)
変更の種類 (Types of changes)
変更内容 (Changes)
parseAppDir.tsを文字列連結中心の実装から、状態を保持するクラスOutputObjectに移行。追加の背景・補足 (Additional context)
問題を解決しつつ、無理のない範囲で既存の出力と同じになるように心がけています。
(出力の並び順など)
背景
既存実装ではルートグループのマージが困難だったため、クラス化しました。
クラス内で objectKey を管理し、同一レベルに同じキーが重複出力される問題を解消しました。
副作用
,の有無が一部変わります。, が必須の箇所では正しく出力されていることを確認したため、追加修正は行っていません。
知識
parseAppDir.ts以外のファイルについてあまり理解できていません。🙇♂️テストのパス状況
,の差分を除きパスしています。コミュニティノート (Community note)
賛同される方は 👍 リアクションで Upvote をお願いします。
Types of changes
Changes
parseAppDir.tsfrom a string-concatenation implementation to a statefulOutputObjectclass.Additional context
The fix keeps the generated output identical to the previous version wherever reasonably possible—for example, it preserves the original ordering of entries in the output.
Background
Because the previous implementation made it difficult to merge route groups, the logic was converted to a class-based design.
objectKeyis now managed inside the class to eliminate duplicate keys at the same level.Side effects
,in some generated type definitions has changed.Commas are still emitted where required, so no further adjustments have been made.
Known limitations
I am not very familiar with files other than
parseAppDir.tsin pathpida. 🙇♂️Test status
Community note
Please upvote with reacting as 👍 to express your agreement.