Skip to content

fix: generics applied to external component files - #421

Merged
DylanPiercey merged 1 commit into
mainfrom
generics-on-external-component-file
Nov 14, 2025
Merged

fix: generics applied to external component files#421
DylanPiercey merged 1 commit into
mainfrom
generics-on-external-component-file

Conversation

@DylanPiercey

Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot

changeset-bot Bot commented Nov 14, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 43f4a6c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@marko/language-tools Patch
@marko/language-server Patch
@marko/type-check Patch
marko-vscode Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@DylanPiercey
DylanPiercey merged commit f201739 into main Nov 14, 2025
4 checks passed
@DylanPiercey
DylanPiercey deleted the generics-on-external-component-file branch November 14, 2025 16:00
@coderabbitai

coderabbitai Bot commented Nov 14, 2025

Copy link
Copy Markdown

Walkthrough

This pull request introduces a new test fixture for a generic class-based Marko component and updates the script extractor logic for handling external components. The test fixture comprises a TypeScript class extending Marko.Component<Input<T>> with generic type support, paired with a Marko template file defining a generic Input<T> interface. The extractor changes modify how imports are generated for external components: TypeScript components with type parameters now use typed imports instead of interface declarations, while both TypeScript and JavaScript components without type parameters use computed import paths. Non-TypeScript components additionally switch to JSDoc-style import annotations when type parameters are present.

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive No pull request description was provided by the author, making it impossible to assess whether a description relates to the changeset. Add a pull request description explaining the bug being fixed and how the changes address generic type parameters in external component files.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: generics applied to external component files' clearly summarizes the main change, which involves handling generic type parameters in external component files across the test fixtures and script extractor.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 generics-on-external-component-file

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9faf4f5 and 43f4a6c.

⛔ Files ignored due to path filters (4)
  • .changeset/swift-cloths-train.md is excluded by none and included by none
  • packages/language-server/src/__tests__/fixtures/script/class-api-with-generics-and-component-auto-import/__snapshots__/class-api-with-generics-and-component-auto-import.expected/index.html is excluded by !**/__snapshots__/** and included by **/src/**
  • packages/language-server/src/__tests__/fixtures/script/class-api-with-generics-and-component-auto-import/__snapshots__/class-api-with-generics-and-component-auto-import.expected/index.md is excluded by !**/__snapshots__/** and included by **/src/**
  • packages/language-server/src/__tests__/fixtures/script/class-api-with-generics-and-component-auto-import/__snapshots__/class-api-with-generics-and-component-auto-import.expected/index.ts is excluded by !**/__snapshots__/** and included by **/src/**
📒 Files selected for processing (3)
  • packages/language-server/src/__tests__/fixtures/script/class-api-with-generics-and-component-auto-import/component.ts (1 hunks)
  • packages/language-server/src/__tests__/fixtures/script/class-api-with-generics-and-component-auto-import/index.marko (1 hunks)
  • packages/language-tools/src/extractors/script/index.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/language-server/src/__tests__/fixtures/script/class-api-with-generics-and-component-auto-import/component.ts (1)
packages/language-server/src/__tests__/fixtures/script/class-api-with-generics-and-component-auto-import/__snapshots__/class-api-with-generics-and-component-auto-import.expected/index.ts (1)
  • Input (1-3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test: node@22
🔇 Additional comments (3)
packages/language-tools/src/extractors/script/index.ts (3)

1-8: Well-designed test fixture for generic components.

The fixture exercises key scenarios:

  • Generic interface Input<T> tests type parameter handling
  • Line 5 references a non-existent method "handleClickMissing", which appears intentional for testing error diagnostics
  • Line 6 tests string literal method names ("strange-handler")
  • Line 7 verifies type inference on component.input

1-6: LGTM! Clean generic component implementation.

The component correctly:

  • Imports the generic Input<T> interface using type import
  • Defines a generic class with type parameter T
  • Extends Marko.Component<Input<T>> to properly type the component
  • Includes both standard (handleClick) and string literal ("strange-handler") method names for comprehensive testing

271-291: TypeScript 5.5+ required for JSDoc @import support—verify project compatibility.

TypeScript 5.5 introduced JSDoc @import tag support. The code at lines 271-291 uses this syntax for JavaScript files (when ScriptLang !== ts). Confirm that the project's TypeScript version meets or exceeds 5.5 to ensure the JSDoc @import statements are properly recognized and type-checked.

The refactoring logic itself is sound: generics are imported directly, non-generic components use the ResolveComponent helper, and the extracted componentImport variable improves clarity.


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

@github-actions github-actions Bot mentioned this pull request Nov 14, 2025
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