Skip to content

Conversation

@john-b-yang
Copy link
Member

Adds TypeScript support, addresses #88.

@john-b-yang john-b-yang requested review from acrmp and kabirgh July 2, 2025 19:36
@codecov
Copy link

codecov bot commented Jul 2, 2025

Codecov Report

Attention: Patch coverage is 83.79630% with 35 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
swesmith/bug_gen/adapters/typescript.py 79.16% 35 Missing ⚠️
Files with missing lines Coverage Δ
swesmith/bug_gen/adapters/__init__.py 100.00% <100.00%> (ø)
swesmith/bug_gen/adapters/javascript.py 89.13% <100.00%> (ø)
tests/bug_gen/adapters/test_typescript.py 100.00% <100.00%> (ø)
tests/conftest.py 96.55% <100.00%> (+0.18%) ⬆️
swesmith/bug_gen/adapters/typescript.py 79.16% <79.16%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

("_allocQueue", "_allocQueue()", 70, 84),
(
"_pushQueue",
"_pushQueue(\n char: number,\n repeat: number,\n line: number | undefined,\n column: number | undefined,\n filename: string | undefined,\n) {\n const cu",
Copy link
Collaborator

Choose a reason for hiding this comment

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

It looks like signature includes part of the method body for _pushQueue (and other methods that have multi-line signatures).

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah, this also looks sort of parsed incorrectly... Will simplify def signature, it's a little complicated now that I'm looking at it.

@@ -0,0 +1,520 @@
import type SourceMap from "./source-map.ts";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like to include the details of the original source in the commit when vendoring code for a fixture. I think it comes from here?
https://github.com/babel/babel/blob/ca998707a1c89da04aa849df9c340e06ce6da955/packages/babel-generator/src/buffer.ts

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense - did you mean adding a comment or something at the top of the file? Like

// Code from https://github.com/babel/babel/blob/ca998707a1c89da04aa849df9c340e06ce6da955/packages/babel-generator/src/buffer.ts

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would normally just include it in the commit message where we add the file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha, I'll do that!

_walk_and_collect_ts(child, entities, lines, file_path, max_entities)
return
elif node.type in [
"function_declaration",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we test for function_declaration handling in the unit tests?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah good point - hmm ok maybe i'll find a better testing file in terms of coverage.

I'm also a little tempted to just add some code to the end of this file. It would change the original source code, but might just be an easier solution. I'll think about this!

@john-b-yang john-b-yang added the help wanted Extra attention is needed label Jul 22, 2025
@john-b-yang
Copy link
Member Author

Leaving this PR open - if anyone wants to, please feel free to pick up where I left off!

I think the implementation is close, it's just that the def signature implementation is currently a bit buggy. Instead of just capturing the method header, it's also including bits of the beginning of the function, which isn't quite right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants