Skip to content

Conversation

matthewnitschke-wk
Copy link

@matthewnitschke-wk matthewnitschke-wk commented Sep 26, 2025

Problem/Solution

Currently the diagnostics field on the reported index file is always empty, regardless on if the typescript indexer detects any diagnostic issues

This information can be especially helpful analysis of a codebase, where questions like "how many deprecations are being used within this package" are asked. This is something that we rely pretty heavily on in scip-dart use cases (which fully indexes all analyzer results)

This PR updates the scip-typescript indexer to start indexing @deprecated jsdoc comments, and assigns the correct Deprecated diagnostic tag. Eventually DiagnosticTag.Unnecessary should be implemented, but this is less beneficial from my point of view

Test plan

A new diagnostics snapshot test was added. This include updating the snapshot generation to be in line with the results from the official scip cli snapshot command: sourcegraph/scip#226

@matthewnitschke-wk
Copy link
Author

@varungandhi-src this PR should be ready for review. Happy to punt on the idea if you'd prefer the scip-typescript indexer not providing this as well

Copy link
Contributor

@varungandhi-src varungandhi-src left a comment

Choose a reason for hiding this comment

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

Overall I think it's fine to add support for features like this; left some inline comments on specifics.

new scip.scip.Diagnostic({
severity: scip.scip.Severity.Information,
code: 'DEPRECATED',
message: deprecatedTag.text?.map(part => part.text).join(''),
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't quite understand when we'll have multiple elements here, and why it's justified to join with '' instead of say ' '. Could you explain that? It'd be good to add a code comment for this.

new Foo()
// ^^^ reference diagnostics 0.0.1 `index.ts`/Foo#
// diagnostic Information:
// > This class is deprecated
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be good to add some test cases for multiline messages with @deprecated to capture whether they work/don't work, and make sure that the final formatting is correct.

class Foo {}
// ^^^ definition diagnostics 0.0.1 `index.ts`/Foo#
// diagnostic Information:
// > This class is deprecated
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a strong feeling on this (we can change it later), but I'm wondering if it makes sense to emit this at the definition site as well. What does the Dart indexer do? I'm thinking of downstream functionality, and it generally doesn't make sense to flag warnings for definitions that are deprecated, but only at usage sites.

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.

2 participants