Skip to content

Introduce Path type alias for path arrays in LiveObjects code#2222

Merged
lawrence-forooghian merged 1 commit into
mainfrom
typealias-Path
May 20, 2026
Merged

Introduce Path type alias for path arrays in LiveObjects code#2222
lawrence-forooghian merged 1 commit into
mainfrom
typealias-Path

Conversation

@lawrence-forooghian
Copy link
Copy Markdown
Collaborator

@lawrence-forooghian lawrence-forooghian commented May 19, 2026

Slightly more readable, I think, especially for string[][].

Summary by CodeRabbit

  • Refactor
    • Standardized path representation across the live-objects plugin and updated related APIs for consistent type usage. No functional behavior changes; improvements are internal and aimed at better consistency and type safety.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Walkthrough

This PR introduces a shared Path type across the liveobjects plugin and standardizes path representation throughout four modules. A new Path type (defined as string[]) replaces inline string[] annotations in method signatures, internal fields, event types, and subscription interfaces.

Changes

Path Type Standardization

Layer / File(s) Summary
Path type definition
src/plugins/liveobjects/path.ts
Exports a new Path type alias representing an object-graph path as an array of string key segments.
LiveObject path calculation refactor
src/plugins/liveobjects/liveobject.ts
getFullPaths() method signature changes from string[][] to Path[] return type; internal DFS stack and currentPath tracking refactored to use Path values.
PathObject internal path handling refactor
src/plugins/liveobjects/pathobject.ts
Constructor path parameter, _path field, and private helper methods (_resolvePath, _escapePath) updated to use Path type instead of string[].
Subscription registration and events refactor
src/plugins/liveobjects/pathobjectsubscriptionregister.ts
SubscriptionEntry.path and PathEvent.path interfaces, exported subscribe() method signature, and internal path helpers (_pathStartsWith, _pathsAreEqual) updated to use Path type.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I am a rabbit in the code-lined glen,
I hop along keys again and again,
A tidy Path now guides my way,
No more arrays that gone astray —
Hooray for shared types, hoppy day! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and directly summarizes the main change: introducing a Path type alias for path arrays in LiveObjects code, which matches the actual changes across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch typealias-Path

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.

@github-actions github-actions Bot temporarily deployed to staging/pull/2222/bundle-report May 19, 2026 17:15 Inactive
@github-actions github-actions Bot temporarily deployed to staging/pull/2222/typedoc May 19, 2026 17:15 Inactive
@github-actions github-actions Bot temporarily deployed to staging/pull/2222/features May 19, 2026 17:15 Inactive
Slightly more readable, I think, especially for `string[][]`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/plugins/liveobjects/liveobject.ts`:
- Line 7: Replace the runtime import of Path with a type-only import: since Path
is declared as a type (export type Path = string[]), update the import statement
that references Path in this module to use TypeScript's type-only import form so
the compiler/transpiler emits no runtime import for Path; locate the import line
importing Path from './path' in src/plugins/liveobjects/liveobject.ts and change
it accordingly so usages of the Path type in this file remain valid but no
runtime import is emitted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 53a539b8-da93-4d81-adfe-2eed42528978

📥 Commits

Reviewing files that changed from the base of the PR and between d3e8b5b and e454f57.

📒 Files selected for processing (4)
  • src/plugins/liveobjects/liveobject.ts
  • src/plugins/liveobjects/path.ts
  • src/plugins/liveobjects/pathobject.ts
  • src/plugins/liveobjects/pathobjectsubscriptionregister.ts

import { ROOT_OBJECT_ID } from './constants';
import { InstanceEvent } from './instance';
import { ObjectData, ObjectMessage, ObjectOperation } from './objectmessage';
import { Path } from './path';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Toolchain settings that affect type-only imports =="
fd -HI 'tsconfig*.json' -t f | while read -r f; do
  echo "-- $f"
  rg -n '"verbatimModuleSyntax"|"importsNotUsedAsValues"|"isolatedModules"' "$f" || true
done

fd -HI 'babel*.json|babel*.js|.swcrc|package.json' -t f | while read -r f; do
  echo "-- $f"
  rg -n '`@babel/preset-typescript`|onlyRemoveTypeImports|swc' "$f" || true
done

echo
echo "== Value imports of Path from ./path =="
rg -nP "import\s+\{\s*Path\s*\}\s+from\s+'\.\/path';" --type=ts

echo
echo "== Type-only imports of Path from ./path =="
rg -nP "import\s+type\s+\{\s*Path\s*\}\s+from\s+'\.\/path';" --type=ts || true

Repository: ably/ably-js

Length of output: 24586


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Check Path export in path.ts ==="
cat -n "src/plugins/liveobjects/path.ts" | head -50

echo ""
echo "=== Check Path usage in liveobject.ts ==="
cat -n "src/plugins/liveobjects/liveobject.ts" | head -100

echo ""
echo "=== Check Path usage in pathobject.ts ==="
cat -n "src/plugins/liveobjects/pathobject.ts" | head -100

echo ""
echo "=== Check Path usage in pathobjectsubscriptionregister.ts ==="
cat -n "src/plugins/liveobjects/pathobjectsubscriptionregister.ts" | head -100

echo ""
echo "=== Check tsconfig.json for relevant settings ==="
cat "tsconfig.json" | grep -A 20 "compilerOptions"

Repository: ably/ably-js

Length of output: 12892


🏁 Script executed:

#!/bin/bash
# Quick check to see how Path is actually used in the method bodies of liveobject.ts
# to confirm it's truly type-only and not used at runtime

rg -A 5 "getFullPaths" src/plugins/liveobjects/liveobject.ts | head -30

Repository: ably/ably-js

Length of output: 412


Use a type-only import for Path.

Since Path is declared as export type Path = string[], import it with import type syntax to signal that it's a type-only symbol and avoid runtime import emission issues with stricter TypeScript configurations or transpilers.

Suggested patch
-import { Path } from './path';
+import type { Path } from './path';
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/plugins/liveobjects/liveobject.ts` at line 7, Replace the runtime import
of Path with a type-only import: since Path is declared as a type (export type
Path = string[]), update the import statement that references Path in this
module to use TypeScript's type-only import form so the compiler/transpiler
emits no runtime import for Path; locate the import line importing Path from
'./path' in src/plugins/liveobjects/liveobject.ts and change it accordingly so
usages of the Path type in this file remain valid but no runtime import is
emitted.

@lawrence-forooghian lawrence-forooghian merged commit 238916a into main May 20, 2026
11 of 14 checks passed
@lawrence-forooghian lawrence-forooghian deleted the typealias-Path branch May 20, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants