jinx-rust is a JavaScript/TypeScript library that provides a tolerant parser for the Rust programming language, enabling the development of Rust-specific tooling in TypeScript. As of version 0.1.6, it focuses on being unstrict by default, allowing it to parse malformed or incomplete Rust syntax, which is beneficial for IDEs and linters that need to work with in-progress code. Its release cadence is frequent, with several minor updates addressing parsing fixes since its initial release. A key differentiator is its built-in tolerance for common syntax errors (e.g., missing semicolons, specific Javascript-like operators) and support for 23 Rust nightly features. It also provides a utility sub-package, `jinx-rust/utils`, for common AST traversal and type-checking operations.
npm install jinx-rustVerified import paths — ran on the pinned version, not inferred.
Demonstrates parsing a simple Rust `let` declaration and logging its Abstract Syntax Tree (AST) structure.
Always inspect the generated AST for `MissingNode` or `ErrorNode` types to handle parsing inconsistencies. Be aware that the AST might not reflect perfectly valid Rust.
Prefer using location helpers from `jinx-rust/utils` like `start(node)` for consistent location access, or explicitly use `node.loc.ownStart` when only the node's internal start is needed.
After parsing, if you need a deeper AST for macro arguments or attributes, remember to re-process their token arrays using the appropriate `rs` methods.
Pin exact package versions (e.g., `"jinx-rust": "0.1.6"` instead of `"^0.1.6"`) and carefully review release notes for any updates. Consider waiting for a `1.0.0` release for higher stability in production environments.
Ensure you are using ES module imports: `import { rs } from 'jinx-rust';`. If in a CommonJS environment, check your build configuration for ESM interoperability or consider using a bundler.Utilize type guards or the `is_NodeType()` helpers from `jinx-rust/utils` (e.g., `if (is_FunctionDeclaration(node)) { node.parameters; }`) to narrow down the node type before accessing specific properties.Check for `MissingNode` or `ErrorNode` types in the AST, especially when parsing potentially malformed code. Implement logic to gracefully handle or report these missing nodes, understanding that the AST is incomplete at that point.
No dependency data recorded yet.