Skip to content

refactor(core): type unwrapTs and its each-block/index-key callers - #272

Merged
oekazuma merged 1 commit into
mainfrom
refactor/ast-type-safety-ts-parsers
Jul 22, 2026
Merged

oekazuma merged 1 commit into
mainfrom
refactor/ast-type-safety-ts-parsers

Conversation

@oekazuma

@oekazuma oekazuma commented Jul 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • unwrapTs/isLengthOnlyArrayCall/isIdentityFreeEach/isIndexExpression/isIndexKey in component-parse.ts now use real types (TsExpression, AST.EachBlock, estree's Expression) instead of any.
  • isParentCall/isBodyParseCall in kit-module-parse.ts gained a property.type === 'Identifier' narrowing that unwrapTs's new return type now forces.
  • vite-config-parse.ts needed no changes — its call sites pass any into unwrapTs, which is still valid.
  • Generic AST walkers (e.g. walkEstree) and the rest of these three files stay on the existing Node = any alias; this is intentionally the smallest safe slice, per prior discussion.
  • Added @types/estree as a core devDependency (catalog-pinned) so the package's own tsconfig resolves the estree types it now imports.

Test plan

  • pnpm build
  • pnpm typecheck
  • pnpm test
  • pnpm lint
  • pnpm check:publish
  • packages/action/dist rebuilt and included

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of TypeScript expressions and component syntax during analysis.
    • Increased accuracy when identifying list indexes, list keys, and array patterns.
    • Improved detection of parent and body method calls in performance analysis.

Introduce TsExpression (estree Expression + the three TS wrapper node
types the Svelte script parser emits) so unwrapTs and its direct
callers in component-parse.ts and kit-module-parse.ts get real types
instead of any. Generic AST walkers stay untyped for now.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 247e87a9-e0e0-4995-a2a9-11e325f8a927

📥 Commits

Reviewing files that changed from the base of the PR and between 44a3485 and 5ea50ac.

⛔ Files ignored due to path filters (2)
  • packages/action/dist/index.js is excluded by !**/dist/**
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • packages/core/package.json
  • packages/core/src/component-parse.ts
  • packages/core/src/kit-module-parse.ts

📝 Walkthrough

Walkthrough

The PR adds typed ESTree and Svelte AST handling for component expression analysis, tightens {#each} index-key detection, adds @types/estree for development, and restricts parent/body parsing call recognition to explicit non-computed member expressions.

Changes

AST analysis updates

Layer / File(s) Summary
Typed component expression analysis
packages/core/package.json, packages/core/src/component-parse.ts
Adds TypeScript AST wrapper types, typed unwrapping, stricter array and index-expression checks, and typed {#each} handling.
Module call-shape checks
packages/core/src/kit-module-parse.ts
Requires parent and body parsing calls to use non-computed member expressions with matching identifier properties.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 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 accurately summarizes the main refactor: typing unwrapTs and its each-block/index-key callers.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@oekazuma
oekazuma merged commit b985df5 into main Jul 22, 2026
8 checks passed
@oekazuma
oekazuma deleted the refactor/ast-type-safety-ts-parsers branch July 22, 2026 11:16
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