fix: export internal interpolation options#1832
Open
ErnestM1234 wants to merge 1 commit into
Open
Conversation
Comment on lines
+1
to
+2
| import type { StringFormat } from '@generaltranslation/format/types'; | ||
| import type { NormalizedLookupOptions } from './translation-functions/types/options'; |
Contributor
There was a problem hiding this comment.
Duplicate type alias instead of re-export
InterpolationOptions is already defined and exported from ./translation-functions/utils/interpolation/interpolateMessage (line 13 of that file) as NormalizedLookupOptions<StringFormat>. Creating a second, independent alias here means the two definitions can drift if the source type ever changes, and it forces two new import type statements that serve no other purpose. Using export type { InterpolationOptions } from the source file would be bundle-safe (type-only exports carry no runtime weight) and keeps a single canonical definition.
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/i18n/src/internal.ts
Line: 1-2
Comment:
**Duplicate type alias instead of re-export**
`InterpolationOptions` is already defined and exported from `./translation-functions/utils/interpolation/interpolateMessage` (line 13 of that file) as `NormalizedLookupOptions<StringFormat>`. Creating a second, independent alias here means the two definitions can drift if the source type ever changes, and it forces two new `import type` statements that serve no other purpose. Using `export type { InterpolationOptions }` from the source file would be bundle-safe (type-only exports carry no runtime weight) and keeps a single canonical definition.
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
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.
Summary
Verification
Greptile Summary
This PR exports the
InterpolationOptionstype from thegt-i18n/internalentry point, accompanied by a patch changeset, so that consumers of the internal API have access to that type without reaching into private modules.export type InterpolationOptions = NormalizedLookupOptions<StringFormat>is added tointernal.ts, along with two supportingimport typestatements — however, an identical type alias already exists and is exported frominterpolateMessage.ts; re-exporting from that file directly would avoid the duplication.patchforgt-i18nwith an accurate description.Confidence Score: 4/5
The change is a pure type export with no runtime impact; the type itself is correct and structurally matches the existing definition.
The newly added
InterpolationOptionsalias ininternal.tsis an independent redefinition of the same type that already lives ininterpolateMessage.ts. While this won't cause any runtime breakage, it creates two canonical locations for the same type that could silently diverge under future edits. Everything else — the changeset scope, the generic instantiation, and the surrounding exports — looks correct.packages/i18n/src/internal.ts — the duplicate type alias at line 31 is the only item worth revisiting.
Important Files Changed
InterpolationOptionstype alias and two supporting imports; the alias duplicates an identical definition already exported frominterpolateMessage.ts, which could be re-exported directly instead.gt-i18ndescribing the new type export; content is accurate and correctly scoped.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A["@generaltranslation/format/types\n(StringFormat)"] --> B C["translation-functions/types/options\n(NormalizedLookupOptions)"] --> B B["interpolateMessage.ts\nexport type InterpolationOptions =\nNormalizedLookupOptions<StringFormat>"] A --> D C --> D D["internal.ts\nexport type InterpolationOptions =\nNormalizedLookupOptions<StringFormat>\n⚠ duplicate alias"] B -->|"already exports\nInterpolationOptions"| E["gt-i18n/internal\n(public API)"] D -->|"also exports\nInterpolationOptions"| E style D fill:#fffbe6,stroke:#f0a500 style B fill:#e6f4ea,stroke:#34a853%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A["@generaltranslation/format/types\n(StringFormat)"] --> B C["translation-functions/types/options\n(NormalizedLookupOptions)"] --> B B["interpolateMessage.ts\nexport type InterpolationOptions =\nNormalizedLookupOptions<StringFormat>"] A --> D C --> D D["internal.ts\nexport type InterpolationOptions =\nNormalizedLookupOptions<StringFormat>\n⚠ duplicate alias"] B -->|"already exports\nInterpolationOptions"| E["gt-i18n/internal\n(public API)"] D -->|"also exports\nInterpolationOptions"| E style D fill:#fffbe6,stroke:#f0a500 style B fill:#e6f4ea,stroke:#34a853Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix: export internal interpolation optio..." | Re-trigger Greptile