agent: Add more Rust code examples, update TODO check (#28737)

Release Notes:

- N/A
This commit is contained in:
Thomas Mickley-Doyle 2025-04-15 11:52:08 -05:00 committed by GitHub
parent d0f806456c
commit b1e4e6048a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 142 additions and 2 deletions

View file

@ -0,0 +1,3 @@
url = "https://github.com/swc-project/swc.git"
revision = "787d5fabf410fafe6595ec00c197181b27578cb1"
language_extension = "rs"

View file

@ -0,0 +1,6 @@
1. The `parse` and `parse_sync` functions must support both `Buffer` and `String` inputs for the `src` parameter, using the `Either` type from `napi` to avoid breaking existing string-based usage while adding buffer support.
2. A helper function `stringify` must handle conversion of `Either<Buffer, String>` to a unified `String` representation internally, ensuring consistent UTF-8 decoding for buffers and direct string passthrough.
3. The TypeScript binding declarations (`binding.d.ts`) must reflect the updated parameter types for `parse` and `parse_sync` to accept `Buffer | string`, ensuring compatibility with JavaScript/TypeScript callers.
4. Unit tests must validate both buffer and string input paths for asynchronous (`parse`) and synchronous (`parse_sync`) APIs, ensuring parity in functionality and output correctness.
5. The `filename` parameter must remain optional but use `FileName::Real` when provided and fall back to `FileName::Anon` if omitted, preserving existing file resolution logic.
6. No regressions in error handling, abort signal support, or serialization/deserialization of `ParseOptions` during the refactor.

View file

@ -0,0 +1 @@
I need to extend the SWC parsing APIs to support both `Buffer` and `string` inputs for the source code. Please update the `parse` and `parse_sync` functions to accept `Either<Buffer, String>` instead of just `String`. Add a helper function to convert the `Either` type into a UTF-8 string, using `String::from_utf8_lossy` for buffers to handle invalid characters gracefully. Ensure the TypeScript definitions in `binding.d.ts` reflect the new parameter types. Include unit tests for both buffer and string inputs in `api_test.js`, verifying that asynchronous and synchronous parsing produce identical results regardless of input type. Maintain backward compatibility with existing string-based calls and ensure the `filename` fallback logic remains unchanged. Simplify the `src` handling to avoid code duplication between async/sync paths.