E531 feat: add support for TypeScript declaration files (.d.ts) by reddyeswaranush · Pull Request #512 · CodeGraphContext/CodeGraphContext · GitHub
[go: up one dir, main page]

Skip to content

feat: add support for TypeScri 10BC0 pt declaration files (.d.ts)#512

Open
reddyeswaranush wants to merge 3 commits intoCodeGraphContext:mainfrom
reddyeswaranush:feat-dts-support
Open

feat: add support for TypeScript declaration files (.d.ts)#512
reddyeswaranush wants to merge 3 commits intoCodeGraphContext:mainfrom
reddyeswaranush:feat-dts-support

Conversation

@reddyeswaranush
Copy link

Fixes #467

What this PR does

  • Adds support for indexing TypeScript declaration files (.d.ts)
  • Parses only type-level constructs (interfaces, types, enums, function signatures)
  • Skips runtime-specific nodes and CALLS edges

Implementation details

  • .d.ts files are included in the TypeScript parsing pipeline
  • Runtime constructs are ignored to avoid incorrect CALLS relationships
  • Import resolution works correctly across .ts and .d.ts files

How tested

  • Added sample_dts.d.ts to sample_project_typescript
  • Ran cgc index sample_project_typescript
  • Verified getUser has no callers
  • Verified graph output via Neo4j visualization (screenshot attached)
Screenshot 2026-01-13 011533

@vercel
Copy link
vercel bot commented Jan 12, 2026

Someone is attempting to deploy a commit to the shashankss1205's projects Team on Vercel.

A member of the Team first needs to authorize it.

@reddyeswaranush
Copy link
Author

Hi @Shashankss1205

This PR is ready from my side. The only failing check is the Vercel deployment, which seems to require maintainer authorization for forked PRs.
Could you please approve the workflow or let me know if you’d like me to make any changes?

Thanks!

@reddyeswaranush
Copy link
Author

Hi @Shashankss1205, just a gentle follow-up

The PR looks ready from my side. The only failing check is the Vercel deployment, which I believe requires maintainer approval for forked PRs.

Whenever you get a chance, could you please approve or skip the Vercel check?
Thanks!

@reddyeswaranush
Copy link
Author

Hi @Shashankss1205

Just checking in once more. The code review feedback has been addressed and the PR looks ready from my side.

The only remaining failing check is the Vercel deployment, which seems to require maintainer approval for forked PRs.
Whenever you have time, could you please approve or skip that check?

Thanks a lot!

@Shashankss1205
Copy link
Collaborator

please answer this question:
why do we define DTS_ALLOWED_NODES ?

@reddyeswaranush
Copy link
Author

@Shashankss1205 We define DTS_ALLOWED_NODES to limit what we extract from .d.ts files to only declaration-level constructs.

Even though .d.ts files don’t contain runtime logic, tree-sitter still produces a full AST that includes nodes similar to implementation code. If we don’t explicitly restrict this, we can end up creating misleading nodes or relationships (like runtime functions or CALLS edges) from declaration files.

Having DTS_ALLOWED_NODES makes the intent clear:

  • only interfaces, types, enums, and function signatures are indexed
  • runtime-specific constructs are ignored
  • .d.ts behavior stays clearly separated from normal .ts parsing

It also keeps the logic explicit and easier to maintain instead of relying on scattered condition checks.

@Shashankss1205
Copy link
Collaborator

I dont see it being used anywhere. If its just for help, you should replace it as a comment instead!

Removed DTS_ALLOWED_NODES constant and added notes about indexing.
@reddyeswaranush
Copy link
Author

Done @Shashankss1205
I converted DTS_ALLOWED_NODES into a comment since it wasn’t being enforced directly.

@reddyeswaranush
Copy link
Author

Hi @Shashankss1205
I’ve updated the PR as suggested and replaced DTS_ALLOWED_NODES with a comment since it wasn’t being enforced directly.

Whenever you get a chance, could you please take a look?
Thanks!

@reddyeswaranush
Copy link
Author

Hi @Shashankss1205
I’ve updated the PR as suggested and replaced DTS_ALLOWED_NODES with a comment since it wasn’t being enforced directly.

Whenever you get a chance, could you please take a look?
Thanks!

@Shashankss1205
Copy link
Collaborator

Thanks @reddyeswaranush Will merge this PR today! Sorry for keeping it on hold for so long

@reddyeswaranush
Copy link
Author

Sure @Shashankss1205 no worries 😊

@reddyeswaranush
Copy link
Author

Hi @Shashankss1205

This PR is ready from my side. The only failing check is the Vercel deployment, which seems to require maintainer authorization for forked PRs.
Could you please approve the workflow or let me know if you’d like me to make any changes?

Thanks!

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.

Add support for TypeScript declaration files (.d.ts)

2 participants

0