chore(deps): replace candid next branch with published candid 0.10.30 / candid_parser 0.4.0#147
Merged
Merged
Conversation
Migrate the bindgen crate off the floating `candid`/`candid_parser` `next` branch. Deps now point at the candid PR branch (named-args parser support); they will switch to the published `candid` 0.10 / `candid_parser` 0.4 releases once dfinity/candid#742 is merged and released. `candid` 0.10's `Function`/`Class` do not carry argument names, so: - `parser.rs` builds nameless `candid::types::Function` and keys `TypeEnv` by `String` (no `ArgType` / `TypeKey`). - The TypeScript binding generators recover argument names from the parser AST (`syntax::IDLArgType.name`) threaded alongside the checked types, so service-method and func-type signatures keep meaningful parameter names and fall back to positional `arg{i}` only where the AST has none. Builds clean for host and wasm32-unknown-unknown. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
candid 0.10's `TypeEnv` is a `BTreeMap<String, Type>` that iterates in alphabetical order, whereas the old candid `next` branch iterated in an arbitrary internal order. The native TypeScript generator walked the env directly (`env.0.keys()`), so its declaration order flipped after the candid migration, breaking the `example` snapshots. Iterate via `env.to_sorted_iter()` instead, matching the original-format generators in typescript.rs / javascript.rs. Ordering is now intentional and independent of candid's internal `TypeEnv` representation. Regenerated snapshots are pure reorderings — generated content is byte-identical. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
next branch with published candid 0.10.30 / candid_parser 0.4.0
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Rust bindgen generator to stop depending on the floating candid / candid_parser next branch and instead pin to published releases, while preserving named-argument output for TypeScript by recovering argument names from the Candid parser AST and making type emission deterministic.
Changes:
- Pin
candid/candid_parserto crates.io releases (0.10.30/0.4.0) and update affected generator code to match the stable 0.10 type model. - Adjust parsing/binding generation to drop argument names from checked
candid::types::Functionand recover them from the syntax AST when emitting TS signatures. - Emit TS native type definitions in sorted order and update snapshot expectations accordingly.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/snapshots/wasm-generate/typescript/example/example.ts.snapshot | Updates expected TS output ordering/determinism after generator changes. |
| tests/snapshots/wasm-generate/typescript-root-export/example/example.ts.snapshot | Updates expected TS output ordering/determinism for root-export variant. |
| tests/snapshots/wasm-generate/root-export/example/example.ts.snapshot | Updates expected TS output ordering/determinism for wasm root-export path. |
| tests/snapshots/wasm-generate/root-export/example/example.d.ts.snapshot | Updates expected .d.ts output ordering/determinism for wasm root-export path. |
| tests/snapshots/wasm-generate/no-root-export/example/example.ts.snapshot | Updates expected TS output ordering/determinism for no-root-export path. |
| tests/snapshots/wasm-generate/no-root-export/example/example.d.ts.snapshot | Updates expected .d.ts output ordering/determinism for no-root-export path. |
| tests/snapshots/generate/example/example.ts.snapshot | Updates expected host-generate TS output ordering/determinism. |
| tests/snapshots/generate/example/example.d.ts.snapshot | Updates expected host-generate .d.ts output ordering/determinism. |
| src/core/generate/rs/src/parser.rs | Drops ArgType argument-name retention in checked types; uses stable 0.10 TypeEnv keying and function arg/ret types. |
| src/core/generate/rs/src/bindings/typescript.rs | Updates TS printer to the stable 0.10 Function arg/ret representation. |
| src/core/generate/rs/src/bindings/typescript_native/original_typescript_types.rs | Removes TypeKey usage and updates var type creation to use &str. |
| src/core/generate/rs/src/bindings/typescript_native/new_typescript_native_types.rs | Adds sorted emission and recovers argument names from syntax AST for TS native signatures. |
| src/core/generate/rs/src/bindings/typescript_native/conversion_functions_generator.rs | Updates multi-return conversion to use &[Type] instead of &[ArgType]. |
| src/core/generate/rs/src/bindings/typescript_native/compile_wrapper.rs | Removes TypeKey usage and updates conversions to stable 0.10 function type shapes. |
| src/core/generate/rs/src/bindings/javascript.rs | Updates JS/TS IDL runtime printer to stable 0.10 function arg/ret representation. |
| src/core/generate/rs/Cargo.toml | Pins candid and candid_parser to published versions. |
| Cargo.lock | Updates lockfile to reflect crates.io dependencies and transitive changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…orts The native TS generator computed a synthetic `span` carrying each type's leading doc comment (via `add_comments`) but then used `DUMMY_SP` on the `ExportDecl` for record, service, function, and variant types — so their type-level IDL doc comments were silently dropped from the generated output (only the `Var` and fallback arms used the span). Use the computed `span` on all four export sites, matching those working arms. Doc-comment escaping is unchanged: the `malicious_doc` fixture confirms `*/` sequences in newly-emitted type-level comments are escaped to `*\/`, so they cannot break out of the JSDoc block. Reported by Copilot review on #147. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
adamspofford-dfinity
approved these changes
Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Decouples the bindgen crate from the floating
candid/candid_parsernextbranch and pins it to the publishedcandid0.10.30 /candid_parser0.4.0 releases.Why
candid
nextcarried breaking changes — named args baked intocandid::types::Function, aHashMap/TypeKey-basedTypeEnv, and a serde rewrite — that are not headed to a stable release. Depending on it tied the build to a moving target. This PR keeps candid on its stable 0.10 type model and recovers the only feature the bindgen actually needs — named function arguments — from the parser AST instead.Changes
candid/candid_parser→ published0.10.30/0.4.0(was thenextbranch).parser.rs: builds namelesscandid::types::Function/Classand keysTypeEnvbyString(noArgType/TypeKey).syntax::IDLArgType.name), threaded alongside the checked types. Service-method and func-type-alias signatures keep meaningful parameter names; nested/anonymous funcs fall back to positionalarg{i}(valid TS).to_sorted_iter, matching the original-format generators, so output is deterministic regardless of candid's internalTypeEnvrepresentation.Test plan
cargo build(host) andcargo build --target wasm32-unknown-unknown— cleancargo fmt --check/cargo clippy— cleanvitest) — 52/52 passing, type-check clean🤖 Generated with Claude Code