Skip to content

Report declaration-only TypeScript in JSON language detection - #252

Open
swpswpswp wants to merge 1 commit into
git-pkgs:mainfrom
swpswpswp:fix/typescript-declaration-only
Open

swpswpswp wants to merge 1 commit into
git-pkgs:mainfrom
swpswpswp:fix/typescript-declaration-only

Conversation

@swpswpswp

@swpswpswp swpswpswp commented Nov 19, 2026 •

Copy link
Copy Markdown

Summary

A TypeScript entry in brief --json now includes declarations_only when there is matching file evidence. It is true for declaration files only, false when at least one implementation file is present, and omitted when only configuration or dependency evidence detected TypeScript. The check uses the same bounded file index and language-evidence filters as detection.

TypeScript matching also recognizes .mts, .cts, and nested .tsx files. Both .d.mts and .d.cts count as declarations.

Fixes #251.

Validation

  • Reproduced the missing distinction and missing module-file detection on f037b36.
  • Seven new CLI JSON cases pass, including files in excluded fixture and build directories. The focused detection suite and go vet ./... pass.
  • The generated schema exposes the optional field as a boolean. The CLI package passes with seven symlink tests omitted. The same tests fail on unchanged main because this Windows account cannot create symlinks.

Implemented with Codex.

Summary by CodeRabbit

  • New Features
    • TypeScript detection now includes .mts and .cts files and searches for .ts and .tsx files recursively.
    • TypeScript results indicate whether matching files are declaration-only. This metadata is omitted when no matching TypeScript files are found.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

TypeScript detection now reports an optional declarations_only field. Its value reflects whether matching TypeScript files are declaration files, implementation files, or absent within the detection scan.

Changes: TypeScript declaration metadata

Layer / File(s) Summary
TypeScript file scope and classification
knowledge/node/typescript.toml, detect/roles.go
The TypeScript patterns include .mts and .cts files and recursive .tsx matches. The classifier checks eligible TypeScript-family files and returns true, false, or nil.
Declaration metadata output and validation
brief.go, detect/detect.go, cmd/brief/main_test.go, README.md
The Detection type adds an optional declarations_only field, which TypeScript detection populates. Scanner tests cover declaration and implementation cases. The README documents the field’s values and scan scope.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: andrew

Merge Risk: Minimal · up to f1abd

This adds an optional declarations_only field to TypeScript entries in brief --json output, and recognizes .mts, .cts, and nested .tsx files. Existing consumers are unaffected because the field is omitted when unset. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: TypeScript detections in the JSON language output now report a declaration-only flag. The raw summary and PR objectives confirm this: an optional declarations_only fie…
Linked Issues check Passed Issue #251 requires that brief --json distinguish TypeScript declaration-file evidence from implementation-file evidence, including .d.mts and .d.cts, without a rescan. At head f1abd8e, `brief.g…
Out of Scope Changes check Passed The changes map to #251 or support it. brief.go, detect/detect.go, detect/roles.go, and the test file implement the new field. The knowledge/node/typescript.toml change adds .mts and .cts …
Full details: Title check

Explanation

The title names the main change: TypeScript detections in the JSON language output now report a declaration-only flag. The raw summary and PR objectives confirm this: an optional declarations_only field is added to TypeScript entries in brief --json, set from matching file evidence, and true only when all matched TypeScript files are declarations. The title is specific and concise, and it matches the changeset.

Full details: Linked Issues check

Explanation

Issue #251 requires that brief --json distinguish TypeScript declaration-file evidence from implementation-file evidence, including .d.mts and .d.cts, without a rescan. At head f1abd8e, brief.go adds Detection.DeclarationsOnly *bool with json:"declarations_only,omitempty". detect/detect.go sets it for TypeScript using Engine.typeScriptDeclarationsOnly() in detect/roles.go. That function reads the already-loaded projectFiles and applies languageEvidence. It returns false when a non-declaration .ts, .tsx, .mts, or .cts file is found. It returns true when only declaration files are found (.d.ts, .d.mts, .d.cts). It returns nil (omitted) when no matching file exists, which covers config or dependency-only detection. This meets the field semantics in the issue. cmd/brief/main_test.go adds TestScanReportsTypeScriptDeclarationOnly covering these cases. I did not run the tests. The comparison in this review relies on the diff and the PR's reported validation.

Full details: Out of Scope Changes check

Explanation

The changes map to #251 or support it. brief.go, detect/detect.go, detect/roles.go, and the test file implement the new field. The knowledge/node/typescript.toml change adds .mts and .cts patterns and makes .ts and .tsx patterns recursive (**/). This is needed so the field classifies .d.mts and .d.cts files, which the issue requests. The recursive .tsx and **/*.ts patterns broaden TypeScript detection beyond #251. The PR description and objectives disclose this broadening, and it uses the same bounded file index. It is not an unrelated change. No unrelated file changes appear in the summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 302aa963-2f6c-4d6e-8e9d-f84c88349b84
Commits

Reviewing files that changed from the base of the PR and between f037b36 and f1abd8e.

Files selected for processing: 6

  • README.md
  • brief.go
  • cmd/brief/main_test.go
  • detect/detect.go
  • detect/roles.go
  • knowledge/node/typescript.toml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, this does what #251 asks for, and reusing the loaded file index with languageEvidence keeps it cheap. Two small changes before merging:

detect/roles.go: typeScriptDeclarationsOnly hardcodes .ts, .tsx, .mts and .cts, which repeats the patterns in knowledge/node/typescript.toml. If a pattern is later added there, detection will pick it up and this classifier won't. Please pass in the TypeScript tool definition and filter files with its Detect.Files patterns via matchesProjectPattern, keeping the .d suffix check, so both use one list.

brief.go: please drop the comment on DeclarationsOnly. It restates the field name, and none of the other fields in Detection have comments.

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.

Distinguish TypeScript declaration files in language detection output

2 participants