Skip to content

[issues/255] PR4.5: Type→Kind Naming Consistency + Test Type Patterns#309

Merged
couimet merged 2 commits intomainfrom
issues/255-pr4.5-type-to-kind
Feb 6, 2026
Merged

[issues/255] PR4.5: Type→Kind Naming Consistency + Test Type Patterns#309
couimet merged 2 commits intomainfrom
issues/255-pr4.5-type-to-kind

Conversation

@couimet
Copy link
Owner

@couimet couimet commented Feb 6, 2026

Comprehensive naming cleanup that aligns type names with the kind property convention used throughout the codebase, plus improves test type safety by replacing jest.Mocked<T> with ReturnType<typeof createMockT> patterns. This is a code quality improvement with no user-facing changes.

  • Renamed DestinationTypeDestinationKind across all source and test files

  • Renamed AIAssistantDestinationTypeAIAssistantDestinationKind

  • Renamed DESTINATION_TYPESDESTINATION_KINDS constant

  • Renamed AI_ASSISTANT_TYPESAI_ASSISTANT_KINDS constant

  • Renamed method getSupportedTypes()getSupportedKinds() in DestinationRegistry

  • Renamed function isPasteDestinationType()isPasteDestinationKind() in type guards

  • Renamed option destinationTypesdestinationKinds in GetAvailableDestinationItemsOptions

  • Renamed property destinationTypedestinationKind in QuickPickItems and logging contexts

  • File renamed: DestinationType.tsDestinationKind.ts

  • Replaced jest.Mocked<DestinationAvailabilityService> with ReturnType<typeof createMockDestinationAvailabilityService>

  • Replaced jest.Mocked<PasteDestination> with appropriate ReturnType<typeof createMock*Destination> patterns

  • Removed now-unused type imports that were only needed for jest.Mocked declarations

  • Applied pattern consistently across BindToTerminalCommand.test.ts, RangeLinkStatusBar.test.ts, and PasteDestinationManager.test.ts

  • Extracted WithDestinationKind interface to types/WithDestinationKind.ts

  • Extracted WithDisplayName interface to types/WithDisplayName.ts

  • BindOptions.ts now extends WithDestinationKind instead of local BaseBindOptions

  • AvailableDestination now composes WithDestinationKind and WithDisplayName

  • QuickPickTypes.ts imports and uses WithDisplayName from the shared location

  • Added barrel exports for both new interfaces in types/index.ts

  • Removed re-export of DestinationKind and AIAssistantDestinationKind from PasteDestination.ts

  • Updated all imports to use destination kind types from types/ barrel instead of direct file imports

  • Enforces clean separation: types defined in types/, interfaces defined where used

  • Standardized all imports to use barrel exports instead of direct file imports

  • Source files: Commands, StatusBar, BookmarkService, navigation handlers, utils

  • Test files: All test helpers and test files in tests/

  • Types imported from ../types or ../../types (not ../types/FileName.ts)

  • Destinations imported from ../destinations or ../../destinations

  • i18n imports consolidated through ../i18n barrel

  • errors imports consolidated through ../errors barrel

  • All existing 1396 tests pass

  • No new tests added (refactoring only)

  • Verified no remaining DestinationType references in codebase

  • Verified jest.Mocked<T> replaced with factory return types where createMock* helpers exist

  • Verified no re-export violations (import then export same symbol)

  • Verified all imports use barrel exports (no direct file imports)

  • Part of Terminal Binding - Terminal Picker #255 (Terminal Picker feature stack)

Summary by CodeRabbit

  • Refactor
    • Internal code reorganization and terminology standardization across the codebase, including module import consolidation and type naming alignment.

Comprehensive naming cleanup that aligns type names with the `kind` property convention used throughout the codebase, plus improves test type safety by replacing `jest.Mocked<T>` with `ReturnType<typeof createMockT>` patterns. This is a code quality improvement with no user-facing changes.

- Renamed `DestinationType` → `DestinationKind` across all source and test files
- Renamed `AIAssistantDestinationType` → `AIAssistantDestinationKind`
- Renamed `DESTINATION_TYPES` → `DESTINATION_KINDS` constant
- Renamed `AI_ASSISTANT_TYPES` → `AI_ASSISTANT_KINDS` constant
- Renamed method `getSupportedTypes()` → `getSupportedKinds()` in DestinationRegistry
- Renamed function `isPasteDestinationType()` → `isPasteDestinationKind()` in type guards
- Renamed option `destinationTypes` → `destinationKinds` in GetAvailableDestinationItemsOptions
- Renamed property `destinationType` → `destinationKind` in QuickPickItems and logging contexts
- File renamed: `DestinationType.ts` → `DestinationKind.ts`

- Replaced `jest.Mocked<DestinationAvailabilityService>` with `ReturnType<typeof createMockDestinationAvailabilityService>`
- Replaced `jest.Mocked<PasteDestination>` with appropriate `ReturnType<typeof createMock*Destination>` patterns
- Removed now-unused type imports that were only needed for jest.Mocked declarations
- Applied pattern consistently across BindToTerminalCommand.test.ts, RangeLinkStatusBar.test.ts, and PasteDestinationManager.test.ts

- Extracted `WithDestinationKind` interface to `types/WithDestinationKind.ts`
- Extracted `WithDisplayName` interface to `types/WithDisplayName.ts`
- `BindOptions.ts` now extends `WithDestinationKind` instead of local `BaseBindOptions`
- `AvailableDestination` now composes `WithDestinationKind` and `WithDisplayName`
- `QuickPickTypes.ts` imports and uses `WithDisplayName` from the shared location
- Added barrel exports for both new interfaces in `types/index.ts`

- Removed re-export of `DestinationKind` and `AIAssistantDestinationKind` from `PasteDestination.ts`
- Updated all imports to use destination kind types from `types/` barrel instead of direct file imports
- Enforces clean separation: types defined in `types/`, interfaces defined where used

- Standardized all imports to use barrel exports instead of direct file imports
- Source files: Commands, StatusBar, BookmarkService, navigation handlers, utils
- Test files: All test helpers and test files in __tests__/
- Types imported from `../types` or `../../types` (not `../types/FileName.ts`)
- Destinations imported from `../destinations` or `../../destinations`
- i18n imports consolidated through `../i18n` barrel
- errors imports consolidated through `../errors` barrel

- [x] All existing 1396 tests pass
- [x] No new tests added (refactoring only)
- [x] Verified no remaining `DestinationType` references in codebase
- [x] Verified `jest.Mocked<T>` replaced with factory return types where createMock* helpers exist
- [x] Verified no re-export violations (import then export same symbol)
- [x] Verified all imports use barrel exports (no direct file imports)

- Part of #255 (Terminal Picker feature stack)
- Follows PR4: DestinationPickerCommand and Grouped API
@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

Walkthrough

This pull request refactors destination terminology and import structure throughout the VSCode extension. It renames "type" to "kind" across destination-related types and methods, consolidates imports using barrel exports, introduces new composition-based type interfaces, and moves type definitions to a centralized location.

Changes

Cohort / File(s) Summary
Type System Refactoring
src/types/DestinationKind.ts, src/types/DestinationType.ts, src/types/WithDestinationKind.ts, src/types/WithDisplayName.ts, src/types/index.ts
New DestinationKind.ts introduced with DESTINATION_KINDS, DestinationKind, AI_ASSISTANT_KINDS, and AIAssistantDestinationKind types. Removed all type definitions from DestinationType.ts. Added new composition interfaces WithDestinationKind and WithDisplayName. Updated public exports in index.
Destination Core Services
src/destinations/DestinationRegistry.ts, src/destinations/DestinationAvailabilityService.ts, src/destinations/PasteDestinationManager.ts, src/destinations/ComposablePasteDestination.ts, src/destinations/PasteDestination.ts, src/destinations/destinationBuilders.ts
Renamed method getSupportedTypes()getSupportedKinds(). Updated parameter destinationTypesdestinationKinds. Changed type signatures from DestinationType to DestinationKind throughout. Removed direct type constants from PasteDestination.ts. Updated bind/availability methods to use new kind types and parameter names.
Destination Utilities
src/destinations/utils/buildDestinationQuickPickItems.ts
Renamed type constants and type guards from DestinationType/DESTINATION_TYPES to DestinationKind/DESTINATION_KINDS. Updated DESTINATION_PICKER_SEQUENCE and isDestinationKind predicate accordingly.
Type Interfaces
src/types/AvailableDestination.ts, src/types/BindOptions.ts, src/types/GroupedDestinationKinds.ts, src/types/QuickPickTypes.ts
Changed AvailableDestination from explicit properties to composition extending WithDestinationKind and WithDisplayName. Updated BindOptions interfaces to use WithDestinationKind and DestinationKind. Renamed GroupedDestinationTypesGroupedDestinationKinds. Extracted WithDisplayName to separate module.
Test Files - Core Tests
src/__tests__/RangeLinkService.test.ts, src/__tests__/commands/*.test.ts, src/__tests__/destinations/*.test.ts, src/__tests__/statusBar/*.test.ts
Consolidated imports using barrel exports. Updated type references from DestinationType to DestinationKind. Renamed mock types to use ReturnType<typeof createMock...>. Updated test assertions from destinationTypedestinationKind. Changed method calls from getSupportedTypes()getSupportedKinds() and parameter names from destinationTypesdestinationKinds.
Test Helpers
src/__tests__/helpers/createBaseMockPasteDestination.ts, src/__tests__/helpers/createMock*.ts, src/__tests__/helpers/destinationTestHelpers.ts
Updated imports to use barrel exports. Changed type parameters from DestinationType to DestinationKind. Updated mock helper signatures and type annotations throughout.
Utility Functions
src/utils/destinationKindGuards.ts, src/utils/isSelfPaste.ts, src/utils/formatMessage.ts, src/utils/index.ts
Renamed guard function isPasteDestinationType()isPasteDestinationKind() with corresponding parameter rename. Updated import paths to use barrel exports. Updated re-export source in utils index.
Command and Status Bar
src/commands/BindToTerminalCommand.ts, src/commands/DestinationPickerCommand.ts, src/commands/ListBookmarksCommand.ts, src/commands/ManageBookmarksCommand.ts, src/statusBar/RangeLinkStatusBar.ts
Consolidated imports to barrel exports. Updated property names from destinationTypedestinationKind in QuickPick items. Changed method parameter from destinationTypesdestinationKinds. Updated type imports and references.
Other Modules
src/bookmarks/BookmarkService.ts, src/i18n/messages.en.ts, src/i18n/__tests__/localeCompleteness.test.ts, src/i18n/supportedLocales.ts, src/navigation/RangeLinkNavigationHandler.ts, src/utils/__tests__/destinationKindGuards.test.ts, src/utils/__tests__/formatMessage.test.ts
Updated import paths to use barrel exports. No changes to runtime behavior beyond import consolidation.

Sequence Diagram(s)

The conditions for generating sequence diagrams are not met. While the changes involve multiple components and import restructuring, they consist primarily of terminology renaming, import consolidation, and type system updates without introducing new feature flows or significantly altering control flow sequences.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 Hops through the code with glee so bright,
Kind is the name, not type tonight!
Barrels now barrel the imports home,
No more scattered paths to roam.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: renaming Type to Kind throughout the codebase for naming consistency, plus test type pattern improvements. It directly reflects the core refactor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issues/255-pr4.5-type-to-kind

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (7)
packages/rangelink-vscode-extension/src/__tests__/helpers/createMockDestinationRegistry.ts (1)

90-95: ⚠️ Potential issue | 🟠 Major

getSupportedTypes should be getSupportedKinds to match the interface.

The DestinationRegistry class defines the method as getSupportedKinds() (line 165 of DestinationRegistry.ts), but this mock still uses the old name getSupportedTypes. Any test calling mockRegistry.getSupportedKinds() will get undefined instead of the mocked function.

Fix
   return {
     register: jest.fn(),
     create: jest.fn().mockImplementation(createImpl),
-    getSupportedTypes: jest.fn().mockReturnValue([]),
+    getSupportedKinds: jest.fn().mockReturnValue([]),
     getDisplayNames: jest.fn().mockReturnValue(DEFAULT_DISPLAY_NAMES),
   } as unknown as jest.Mocked<DestinationRegistry>;
packages/rangelink-vscode-extension/src/utils/__tests__/destinationKindGuards.test.ts (1)

21-41: ⚠️ Potential issue | 🟡 Minor

Test descriptions still reference "type" instead of "kind".

Three it descriptions were not updated to match the rename:

  • Line 21: "does not match type""does not match kind"
  • Line 27: "matches type""matches kind"
  • Line 33: "all destination types""all destination kinds"
Suggested fix
-    it('should return false when destination.id does not match type', () => {
+    it('should return false when destination.id does not match kind', () => {
-    it('should return true when destination.id matches type', () => {
+    it('should return true when destination.id matches kind', () => {
-    it('should work with all destination types', () => {
+    it('should work with all destination kinds', () => {
packages/rangelink-vscode-extension/src/destinations/utils/buildDestinationQuickPickItems.ts (1)

68-85: ⚠️ Potential issue | 🟡 Minor

Update error message strings to use "kind" terminology for consistency.

The error messages at lines 71 and 81 still reference "Invalid destination type" while the rest of this file has been migrated to "kind" terminology (isDestinationKind, DESTINATION_KINDS, DestinationKind). Update the message strings to match:

  • Line 71: "Invalid destination kind in picker sequence: ${key}"
  • Line 81: "Invalid destination kind in bindOptions"
Suggested message string updates
    if (!isDestinationKind(key)) {
      throw new RangeLinkExtensionError({
        code: RangeLinkExtensionErrorCodes.UNEXPECTED_DESTINATION_TYPE,
-       message: `Invalid destination type in picker sequence: ${key}`,
+       message: `Invalid destination kind in picker sequence: ${key}`,
        functionName: 'buildDestinationQuickPickItems',
        details: { key },
      });
    }

    for (const item of groupItems as BindableQuickPickItem[]) {
      if (!isDestinationKind(item?.bindOptions?.kind)) {
        throw new RangeLinkExtensionError({
          code: RangeLinkExtensionErrorCodes.UNEXPECTED_DESTINATION_TYPE,
-         message: `Invalid destination type in bindOptions`,
+         message: `Invalid destination kind in bindOptions`,
          functionName: 'buildDestinationQuickPickItems',
          details: { item, key },
        });
      }
packages/rangelink-vscode-extension/src/destinations/DestinationRegistry.ts (1)

84-88: ⚠️ Potential issue | 🟡 Minor

Stale comment: still references "destination type" instead of "destination kind".

Line 85 says "Registry stores builders by destination type" but the rest of the file has been renamed to "kind".

Proposed fix
- * - Registry stores builders by destination type
+ * - Registry stores builders by destination kind
packages/rangelink-vscode-extension/src/destinations/PasteDestinationManager.ts (3)

74-76: ⚠️ Potential issue | 🟡 Minor

Stale JSDoc: "destination type" should be "destination kind".

Line 75 still reads "Bind to a destination type".

Proposed fix
-   * Bind to a destination type
+   * Bind to a destination kind

920-927: ⚠️ Potential issue | 🟡 Minor

Stale log key: currentType should be currentKind.

Line 924 uses currentType as a logging context key, inconsistent with the rest of the rename to "kind".

Proposed fix
       fn: 'PasteDestinationManager.confirmReplaceBinding',
-      currentType: currentDestination.id,
+      currentKind: currentDestination.id,
       newKind,

596-606: ⚠️ Potential issue | 🟡 Minor

Stale error message: "destination type" should be "destination kind" (lines 602, 871).

Two error messages still reference "type":

  • Line 602: Unhandled AI assistant destination type: ${kind}
  • Line 871/874: Unknown destination type '${destination.id}'

These appear in developer-facing error output and should be updated for consistency. Note that changing line 874's message will require updating the corresponding test assertion on line 1260.

Proposed fix
-          message: `Unhandled AI assistant destination type: ${kind}`,
+          message: `Unhandled AI assistant destination kind: ${kind}`,
-          message: `Unknown destination type '${destination.id}' - missing case in buildPasteFailureMessage()`,
+          message: `Unknown destination kind '${destination.id}' - missing case in buildPasteFailureMessage()`,
🧹 Nitpick comments (6)
packages/rangelink-vscode-extension/src/commands/ManageBookmarksCommand.ts (1)

4-5: Nit: Bookmark and BookmarkService imports could be consolidated.

These two type imports from ../bookmarks could be merged into a single line, mirroring the consolidation pattern applied on line 7.

-import type { Bookmark } from '../bookmarks';
-import type { BookmarkService } from '../bookmarks';
+import type { Bookmark, BookmarkService } from '../bookmarks';
packages/rangelink-vscode-extension/src/__tests__/commands/DestinationPickerCommand.test.ts (1)

24-24: Consider aligning jest.Mocked<DestinationAvailabilityService> with the ReturnType<typeof createMock...> pattern.

The PR replaced jest.Mocked<T> with ReturnType<typeof createMockXxx> in BindToTerminalCommand.test.ts, RangeLinkStatusBar.test.ts, and PasteDestinationManager.test.ts, but this file still uses the old pattern on line 24. Applying the same change here would also make the type import on line 8 unnecessary.

♻️ Suggested diff
-import type { DestinationAvailabilityService } from '../../destinations';
 import type { TerminalPickerResult } from '../../destinations/utils';
-  let mockAvailabilityService: jest.Mocked<DestinationAvailabilityService>;
+  let mockAvailabilityService: ReturnType<typeof createMockDestinationAvailabilityService>;
packages/rangelink-vscode-extension/src/types/DestinationKind.ts (1)

27-32: Constrain AI_ASSISTANT_KINDS to DestinationKind values with satisfies for compile-time safety.

Currently AI_ASSISTANT_KINDS is independently typed, so a typo (e.g., 'cursor-ais') would silently create an invalid kind. Add a satisfies constraint to catch such errors at compile time:

♻️ Proposed refinement
-export const AI_ASSISTANT_KINDS = ['claude-code', 'cursor-ai', 'github-copilot-chat'] as const;
+export const AI_ASSISTANT_KINDS = [
+  'claude-code',
+  'cursor-ai',
+  'github-copilot-chat',
+] as const satisfies readonly DestinationKind[];
packages/rangelink-vscode-extension/src/commands/DestinationPickerCommand.ts (1)

3-11: Consolidate error imports from barrel export.

Both RangeLinkExtensionError and RangeLinkExtensionErrorCodes are exported from the ../errors barrel. Combine them into a single import statement for consistency:

Import consolidation
-import { RangeLinkExtensionError } from '../errors';
-import { RangeLinkExtensionErrorCodes } from '../errors/RangeLinkExtensionErrorCodes';
+import { RangeLinkExtensionError, RangeLinkExtensionErrorCodes } from '../errors';
packages/rangelink-vscode-extension/src/__tests__/destinations/DestinationRegistry.test.ts (1)

43-43: Test descriptions still reference "types" instead of "kinds".

Several test description strings still say "types" (e.g., 'should allow registering multiple destination types', 'should overwrite previous builder when registering same type', 'should return registered types', etc.). Since this PR's objective is naming consistency, consider updating these to say "kinds" for alignment.

Also applies to: 53-53, 169-169, 181-181, 202-202, 209-209

packages/rangelink-vscode-extension/src/destinations/DestinationAvailabilityService.ts (1)

227-234: Inconsistency noted: error code name uses "TYPE" while messages reference "kind"—consider revisiting if a naming convention was established for this pattern.

The error code UNEXPECTED_DESTINATION_TYPE is consistently used across 8 locations for destination-level exhaustive checks (all with messages saying "destination kind"), while a separate error code UNEXPECTED_ITEM_KIND exists for item-level checks. The enum defines both as distinct codes with no UNEXPECTED_DESTINATION_KIND variant. If this naming distinction (TYPE vs KIND) reflects an intentional semantic separation, it may warrant a comment explaining the rationale; otherwise, consider aligning the code name to match the message terminology.

Addresses CodeRabbit review feedback on PR #309 by completing the rename from "type" to "kind" throughout the codebase. This includes mock method names, test descriptions, error messages, error codes, JSDoc comments, log keys, and import consolidations.

Benefits:
- Mock method `getSupportedTypes` now matches interface `getSupportedKinds`
- Error code `UNEXPECTED_DESTINATION_TYPE` → `UNEXPECTED_DESTINATION_KIND` for consistency
- All test descriptions now use "kind" terminology
- Added `satisfies` constraint to AI_ASSISTANT_KINDS for compile-time type safety
- Consolidated barrel imports in ManageBookmarksCommand and DestinationPickerCommand
- Standardized test type patterns using `ReturnType<typeof createMock...>`

Ref: #309 (review)
@couimet couimet merged commit f0ae2c6 into main Feb 6, 2026
1 check passed
@couimet couimet deleted the issues/255-pr4.5-type-to-kind branch February 6, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant