refactor(wasm-sdk): remove unchecked_return_type annotations#3088
refactor(wasm-sdk): remove unchecked_return_type annotations#3088thepastaclaw wants to merge 1 commit intodashpay:v3.1-devfrom
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughReplaced occurrences of Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🤖 Fix all issues with AI agents
Before applying any fix, first verify the finding against the current code and
decide whether a code change is actually needed. If the finding is not valid or
no change is required, do not modify code for that item and briefly explain why
it was skipped.
In `@packages/wasm-sdk/src/queries/address.rs`:
- Around line 136-142: Update the TypeScript return type annotations used in the
wasm bindings to reflect that missing entries are serialized as null not
undefined: change the unchecked_return_type declaration (currently
Map<PlatformAddress, PlatformAddressInfo | undefined>) to use
PlatformAddressInfo | null, and do the same for the analogous declaration used
by get_addresses_infos_with_proof_info; update the unchecked_return_type
symbol(s) in packages/wasm-sdk/src/queries/address.rs so the generated TS
signatures accurately match the runtime JsValue::NULL return.
🧹 Nitpick comments (1)
🤖 Fix all nitpicks with AI agents
Before applying any fix, first verify the finding against the current code and decide whether a code change is actually needed. If the finding is not valid or no change is required, do not modify code for that item and briefly explain why it was skipped. In `@packages/wasm-sdk/src/queries/address.rs`: - Around line 136-142: Update the TypeScript return type annotations used in the wasm bindings to reflect that missing entries are serialized as null not undefined: change the unchecked_return_type declaration (currently Map<PlatformAddress, PlatformAddressInfo | undefined>) to use PlatformAddressInfo | null, and do the same for the analogous declaration used by get_addresses_infos_with_proof_info; update the unchecked_return_type symbol(s) in packages/wasm-sdk/src/queries/address.rs so the generated TS signatures accurately match the runtime JsValue::NULL return.packages/wasm-sdk/src/queries/address.rs (1)
136-142: Minor: TS return type saysundefinedbut value is nownull.The
unchecked_return_typeon line 118 declaresMap<PlatformAddress, PlatformAddressInfo | undefined>, but the actual value for missing entries is nownull. Consider updating the type annotation toPlatformAddressInfo | nullfor accuracy. Same applies to line 155 forget_addresses_infos_with_proof_info.This is non-blocking since
unchecked_return_typeis purely for TypeScript hints and doesn't affect runtime behavior.🤖 Prompt for AI Agents
Before applying any fix, first verify the finding against the current code and decide whether a code change is actually needed. If the finding is not valid or no change is required, do not modify code for that item and briefly explain why it was skipped. In `@packages/wasm-sdk/src/queries/address.rs` around lines 136 - 142, Update the TypeScript return type annotations used in the wasm bindings to reflect that missing entries are serialized as null not undefined: change the unchecked_return_type declaration (currently Map<PlatformAddress, PlatformAddressInfo | undefined>) to use PlatformAddressInfo | null, and do the same for the analogous declaration used by get_addresses_infos_with_proof_info; update the unchecked_return_type symbol(s) in packages/wasm-sdk/src/queries/address.rs so the generated TS signatures accurately match the runtime JsValue::NULL return.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
shumkov
left a comment
There was a problem hiding this comment.
If you want to change this interface you need to update all methods that return ProofMetadataResponseWasm and update unchecked_return_type as well
thepastaclaw
left a comment
There was a problem hiding this comment.
Thanks @shumkov — good point. I'll update all the methods returning ProofMetadataResponseWasm and the unchecked_return_type to be consistent. Will push an updated commit.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/wasm-sdk/src/queries/document.rs (1)
449-453:⚠️ Potential issue | 🔴 CriticalFix
get_document_with_proof_infoto explicitly mapNonetoJsValue::NULLinstead of relying onJsValue::from(Option<T>), which producesundefined.The flagged code at lines 449-453 uses
JsValue::from(document_js)wheredocument_jsisOption<DocumentWasm>. In wasm-bindgen, this producesJsValue::UNDEFINEDwhen the value isNone, contradicting the declared return typeDocument | nullon line 417.The same file already handles this correctly in
get_documents(lines 327–334) andget_documents_with_proof_info(lines 362–369) with explicitNone => JsValue::NULLmatch arms. This pattern is consistent across the codebase in identity.rs, address.rs, and group.rs.Proposed fix
- let document_js = document_result - .map(|doc| DocumentWasm::new(doc, contract_id, document_type.to_string(), None)); - - Ok(ProofMetadataResponseWasm::from_sdk_parts( - JsValue::from(document_js), + let document_js = match document_result { + Some(doc) => JsValue::from(DocumentWasm::new( + doc, + contract_id, + document_type.to_string(), + None, + )), + None => JsValue::NULL, + }; + + Ok(ProofMetadataResponseWasm::from_sdk_parts( + document_js, metadata, proof, ))🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/wasm-sdk/src/queries/document.rs` around lines 449 - 453, The returned document_js Option in get_document_with_proof_info should map None to JsValue::NULL instead of using JsValue::from(document_js) which yields undefined; update the construction passed to ProofMetadataResponseWasm::from_sdk_parts to match the pattern used in get_documents/get_documents_with_proof_info by converting document_js with a match that returns JsValue::NULL for None and JsValue::from(doc) for Some(DocumentWasm), referencing the DocumentWasm variable and the call site ProofMetadataResponseWasm::from_sdk_parts to locate where to replace the JsValue::from(document_js) usage.
🧹 Nitpick comments (1)
packages/wasm-sdk/src/queries/identity.rs (1)
1136-1176: Consider aligning token balance map semantics withgetIdentitiesBalances.
getIdentitiesBalances(line 659) declaresMap<Identifier, bigint | null>and insertsJsValue::NULLfor missing entries, ensuring every requested ID appears in the result map. In contrast,getIdentityTokenBalances(line 810) andgetIdentityTokenBalancesWithProofInfo(line 1138) declareMap<Identifier, bigint>and silently skip missing entries — so requested token IDs with no balance are absent from the returned map.This may be intentional (different domain semantics), but it's worth verifying whether callers expect every requested token ID to appear as a key in the result.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/wasm-sdk/src/queries/identity.rs` around lines 1136 - 1176, The token-balance map in get_identity_token_balances_with_proof_info currently omits requested token IDs that have no balance; to match getIdentitiesBalances semantics, iterate the requested token_identifiers and for each missing or None balance insert JsValue::NULL into balances_map instead of skipping; update the loop in get_identity_token_balances_with_proof_info (and mirror the same change in get_identity_token_balances/getIdentityTokenBalances) so every requested Identifier is present in the returned Map, using JsValue::NULL for absent balances while preserving existing present-balance behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/wasm-sdk/src/queries/document.rs`:
- Around line 449-453: The returned document_js Option in
get_document_with_proof_info should map None to JsValue::NULL instead of using
JsValue::from(document_js) which yields undefined; update the construction
passed to ProofMetadataResponseWasm::from_sdk_parts to match the pattern used in
get_documents/get_documents_with_proof_info by converting document_js with a
match that returns JsValue::NULL for None and JsValue::from(doc) for
Some(DocumentWasm), referencing the DocumentWasm variable and the call site
ProofMetadataResponseWasm::from_sdk_parts to locate where to replace the
JsValue::from(document_js) usage.
---
Nitpick comments:
In `@packages/wasm-sdk/src/queries/identity.rs`:
- Around line 1136-1176: The token-balance map in
get_identity_token_balances_with_proof_info currently omits requested token IDs
that have no balance; to match getIdentitiesBalances semantics, iterate the
requested token_identifiers and for each missing or None balance insert
JsValue::NULL into balances_map instead of skipping; update the loop in
get_identity_token_balances_with_proof_info (and mirror the same change in
get_identity_token_balances/getIdentityTokenBalances) so every requested
Identifier is present in the returned Map, using JsValue::NULL for absent
balances while preserving existing present-balance behavior.
|
Good catch on the For the address.rs type annotation nitpick: already For the token balance map semantics: that's an intentional design choice — token balances skip absent entries rather than inserting null. Different domain from identity balances. Also noting the merge conflicts flagged — this PR touches many of the same files as recent v3.1-dev changes, will need a rebase before merge. 🤖 This was generated by an automated review bot. |
shumkov
left a comment
There was a problem hiding this comment.
you need to update js-evo-sdk facades with new types and test for both packages
|
Thanks @shumkov, understood on both points:
Will push the updated implementation. |
|
Updated per review feedback:
Files updated:
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
packages/js-evo-sdk/src/addresses/facade.ts (1)
22-33: JSDoc for proof variants should mentionnullfor absent dataThe
@returnstags forgetWithProofandgetManyWithProofdon't mention that the inner value can benullwhen the address is not found, while their non-proof siblings explicitly documentundefined. Worth a quick doc update for consistency.📝 Suggested JSDoc update
/** * Fetches information about a Platform address with proof. * * `@param` address - The platform address to query (PlatformAddress, Uint8Array, or bech32m string) - * `@returns` ProofMetadataResponse containing PlatformAddressInfo with proof information + * `@returns` ProofMetadataResponse containing PlatformAddressInfo with proof information, or null if not found *//** * Fetches information about multiple Platform addresses with proof. * * `@param` addresses - Array of platform addresses to query - * `@returns` ProofMetadataResponse containing Map of PlatformAddress to PlatformAddressInfo + * `@returns` ProofMetadataResponse containing Map of PlatformAddress to PlatformAddressInfo (null for unfunded addresses) */Also applies to: 48-59
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/js-evo-sdk/src/addresses/facade.ts` around lines 22 - 33, Update the JSDoc for getWithProof and getManyWithProof to explicitly state that the returned ProofMetadataResponse contains an inner value that may be null when the address (or addresses) are not found; locate the methods getWithProof and getManyWithProof in the addresses facade and change their `@returns` descriptions to mention "PlatformAddressInfo | null" (or "Array of PlatformAddressInfo | null items" for getManyWithProof) so the docs match the typed return value.packages/js-evo-sdk/src/documents/facade.ts (1)
19-21:*WithProof→null, non-proof →undefined: mixed absence semantics across the APIAfter this PR, the same conceptual "absent" state is represented differently depending on which call variant is used:
query()→Map<Identifier, Document | undefined>queryWithProof()→Map<Identifier, Document | null>get()→Document | undefinedgetWithProof()→Document | nullThis pattern repeats across all 7 facade files. Consuming code must guard with different idioms depending on whether it calls the proof or non-proof variant. Consider a follow-up to unify non-proof return types to
| nullas well, so the entire API surface uses a single absence idiom.Also applies to: 36-36
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/js-evo-sdk/src/documents/facade.ts` around lines 19 - 21, The API mixes absence semantics (proof variants use null, non-proof use undefined); update the non-proof return types to use null consistently so all methods use the same absence idiom: change signatures and related types for query, get and any other non-proof methods in the facade files (e.g., packages/js-evo-sdk/src/documents/facade.ts and the six sibling facades) from returning Document | undefined or Map<Identifier, Document | undefined> to Document | null and Map<Identifier, Document | null>, and update any internal conversions, callers, and tests to treat absent values as null instead of undefined to keep behavior consistent with queryWithProof/getWithProof.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/js-evo-sdk/src/addresses/facade.ts`:
- Around line 22-33: Update the JSDoc for getWithProof and getManyWithProof to
explicitly state that the returned ProofMetadataResponse contains an inner value
that may be null when the address (or addresses) are not found; locate the
methods getWithProof and getManyWithProof in the addresses facade and change
their `@returns` descriptions to mention "PlatformAddressInfo | null" (or "Array
of PlatformAddressInfo | null items" for getManyWithProof) so the docs match the
typed return value.
In `@packages/js-evo-sdk/src/documents/facade.ts`:
- Around line 19-21: The API mixes absence semantics (proof variants use null,
non-proof use undefined); update the non-proof return types to use null
consistently so all methods use the same absence idiom: change signatures and
related types for query, get and any other non-proof methods in the facade files
(e.g., packages/js-evo-sdk/src/documents/facade.ts and the six sibling facades)
from returning Document | undefined or Map<Identifier, Document | undefined> to
Document | null and Map<Identifier, Document | null>, and update any internal
conversions, callers, and tests to treat absent values as null instead of
undefined to keep behavior consistent with queryWithProof/getWithProof.
|
@thepastaclaw code looks good but you need to fix CI checks |
|
@shumkov The CI failures are infrastructure issues, not related to my code changes:
The code-related checks pass: formatting ✅, structure changes ✅, CodeRabbit ✅. I'll retrigger the flaky wasm-sdk jobs. |
ea048c5 to
0a6a6b9
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
packages/rs-sdk/src/sdk.rs (1)
251-263:⚠️ Potential issue | 🟡 Minor
#[allow(dead_code)]onpub(crate)functions — these are genuinely unused; consider removing or scoping suppression.Both
parse_proof(line 252) andparse_proof_with_metadata(line 292) have no external call sites withinpackages/rs-sdk. The only calls are internal to their own wrapper chain, and production code infetch.rsandfetch_many.rsdirectly callsparse_proof_with_metadata_and_proof, bypassing these wrappers entirely. Using#[allow(dead_code)]masks this signal.Preferred options:
- Remove both wrapper functions if they serve no purpose.
- Scope suppression to a specific build configuration if they are intended for future use:
#[cfg_attr(not(mocks), allow(dead_code))].🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/rs-sdk/src/sdk.rs` around lines 251 - 263, The two wrapper functions parse_proof and parse_proof_with_metadata are unused outside their internal chain and are only bypassed by production callers of parse_proof_with_metadata_and_proof; either remove these wrapper functions entirely (delete parse_proof and parse_proof_with_metadata) or narrow the dead-code suppression to a build-specific cfg (e.g., use a cfg_attr that only allows dead_code when building with mocks) so the dead-code warning isn't globally silenced—update/remove the #[allow(dead_code)] on parse_proof and parse_proof_with_metadata and adjust callers accordingly.packages/js-evo-sdk/src/addresses/facade.ts (1)
112-120:⚠️ Potential issue | 🟡 MinorStale JSDoc:
@returnsstill mentionsundefinedafter the type was changed to| null.📝 Proposed fix
- * `@returns` Map of PlatformAddress to PlatformAddressInfo (or undefined for unfunded addresses) + * `@returns` Map of PlatformAddress to PlatformAddressInfo (or null for unfunded addresses)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/js-evo-sdk/src/addresses/facade.ts` around lines 112 - 120, The JSDoc for topUpIdentity is stale: its `@returns` still says "undefined" even though the function now returns wasm.IdentityTopUpFromAddressesResult | null; update the comment block above async topUpIdentity (in facade.ts, function topUpIdentity) to reflect the new nullable return type and adjust the `@returns` description to mention that the result may be null and under what condition, keeping wording concise and consistent with the actual return type.packages/wasm-sdk/src/queries/data_contract.rs (1)
165-190:⚠️ Potential issue | 🟠 Major
JsValue::from(Option<DataContractWasm>)producesundefined, notnull– type annotation mismatch.The
unchecked_return_typeannotation declares"Map<Identifier, DataContract | null>", but at lines 185–186, converting theOptionviaJsValue::from(value)producesJsValue::UNDEFINEDforNone, notJsValue::NULL. This pattern was already fixed inget_document_with_proof_info(document.rs:456) and throughout other query files (identity.rs, token.rs, group.rs) using explicitmatchstatements.The same issue exists in
get_data_contracts_with_proof_info(lines 246–251).Apply the fix used in document.rs:
match contract { Some(c) => contracts_map.set(&key, &JsValue::from(DataContractWasm::from(c))), None => contracts_map.set(&key, &JsValue::NULL), }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/wasm-sdk/src/queries/data_contract.rs` around lines 165 - 190, The return type annotation declares Map<Identifier, DataContract | null> but get_data_contracts (and get_data_contracts_with_proof_info) currently convert Option<DataContractWasm> with JsValue::from(value), which yields undefined for None; change the conversion to explicitly match the Option and set JsValue::NULL for None and JsValue::from(DataContractWasm::from(c)) for Some(c) (reference symbols: get_data_contracts, get_data_contracts_with_proof_info, DataContractWasm, contracts_map.set, JsValue::NULL).packages/wasm-sdk/src/queries/group.rs (1)
693-716:⚠️ Potential issue | 🟠 MajorFix Map entry handling to use explicit
JsValue::NULLfor None, matching the| nullannotation and the pattern already applied to line 920 and document.rs.The code at lines 714, 741, 809, 878, and 1113 builds Maps where the
unchecked_return_typeclaims values areGroup | nullorGroupAction | null, but usesJsValue::from(opt.map(WasmType::from)). This pattern producesundefinedforNone, notnull. Meanwhile, line 920 (get_group_members_with_proof_info) and document.rs (all Map and from_sdk_parts handling) use explicitmatchwithJsValue::NULL, proving this correction is necessary.The Maps should consistently use:
match opt { Some(item) => JsValue::from(WasmType::from(item)), None => JsValue::NULL, }instead of
JsValue::from(opt.map(...))to ensure the| nullannotations are accurate at runtime.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/wasm-sdk/src/queries/group.rs` around lines 693 - 716, The Map returned by get_group_infos (and similar functions) currently uses JsValue::from(opt.map(GroupWasm::from)) which yields undefined for None; change the value creation to explicitly produce JsValue::NULL for None instead. Locate the map construction in get_group_infos (the closure mapping (position, group_opt) to (key, value)), and replace the JsValue::from(opt.map(...)) usage with a match on group_opt that maps Some(g) => JsValue::from(GroupWasm::from(g)) and None => JsValue::NULL so the JS signature "Group | null" is accurate; apply the same pattern wherever GroupAction or other optional Wasm types are converted for Map::from_entries.
🧹 Nitpick comments (1)
packages/js-evo-sdk/src/identities/facade.ts (1)
77-77: Consider documenting the intentional null-vs-absent asymmetry betweenbalancesandtokenBalances.
balances(line 77) usesMap<wasm.Identifier, bigint | null>— the WASM SDK emitsnullfor an identity that is absent from the proof — whereastokenBalances(line 149) usesMap<wasm.Identifier, bigint>— absent entries are simply omitted from the map. This asymmetry is correct per the upstream WASM design, but a short inline comment would help future maintainers avoid "fixing" one to match the other.📝 Suggested documentation
- async balances(identityIds: wasm.IdentifierLikeArray): Promise<Map<wasm.Identifier, bigint | null>> { + // null map values indicate identities present in the proof but with no recorded balance; + // contrast with tokenBalances where absent entries are omitted entirely. + async balances(identityIds: wasm.IdentifierLikeArray): Promise<Map<wasm.Identifier, bigint | null>> {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/js-evo-sdk/src/identities/facade.ts` at line 77, Add a short inline comment in the balances method explaining the intentional asymmetry with tokenBalances: note that balances (function balances) returns Map<wasm.Identifier, bigint | null> because the upstream WASM SDK emits null for identities that are explicitly absent from the proof, while tokenBalances (function tokenBalances) omits absent identities from the Map; make the comment adjacent to the balances signature or its return handling so future maintainers don't change one to match the other.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@packages/js-evo-sdk/src/addresses/facade.ts`:
- Around line 112-120: The JSDoc for topUpIdentity is stale: its `@returns` still
says "undefined" even though the function now returns
wasm.IdentityTopUpFromAddressesResult | null; update the comment block above
async topUpIdentity (in facade.ts, function topUpIdentity) to reflect the new
nullable return type and adjust the `@returns` description to mention that the
result may be null and under what condition, keeping wording concise and
consistent with the actual return type.
In `@packages/rs-sdk/src/sdk.rs`:
- Around line 251-263: The two wrapper functions parse_proof and
parse_proof_with_metadata are unused outside their internal chain and are only
bypassed by production callers of parse_proof_with_metadata_and_proof; either
remove these wrapper functions entirely (delete parse_proof and
parse_proof_with_metadata) or narrow the dead-code suppression to a
build-specific cfg (e.g., use a cfg_attr that only allows dead_code when
building with mocks) so the dead-code warning isn't globally
silenced—update/remove the #[allow(dead_code)] on parse_proof and
parse_proof_with_metadata and adjust callers accordingly.
In `@packages/wasm-sdk/src/queries/data_contract.rs`:
- Around line 165-190: The return type annotation declares Map<Identifier,
DataContract | null> but get_data_contracts (and
get_data_contracts_with_proof_info) currently convert Option<DataContractWasm>
with JsValue::from(value), which yields undefined for None; change the
conversion to explicitly match the Option and set JsValue::NULL for None and
JsValue::from(DataContractWasm::from(c)) for Some(c) (reference symbols:
get_data_contracts, get_data_contracts_with_proof_info, DataContractWasm,
contracts_map.set, JsValue::NULL).
In `@packages/wasm-sdk/src/queries/group.rs`:
- Around line 693-716: The Map returned by get_group_infos (and similar
functions) currently uses JsValue::from(opt.map(GroupWasm::from)) which yields
undefined for None; change the value creation to explicitly produce
JsValue::NULL for None instead. Locate the map construction in get_group_infos
(the closure mapping (position, group_opt) to (key, value)), and replace the
JsValue::from(opt.map(...)) usage with a match on group_opt that maps Some(g) =>
JsValue::from(GroupWasm::from(g)) and None => JsValue::NULL so the JS signature
"Group | null" is accurate; apply the same pattern wherever GroupAction or other
optional Wasm types are converted for Map::from_entries.
---
Nitpick comments:
In `@packages/js-evo-sdk/src/identities/facade.ts`:
- Line 77: Add a short inline comment in the balances method explaining the
intentional asymmetry with tokenBalances: note that balances (function balances)
returns Map<wasm.Identifier, bigint | null> because the upstream WASM SDK emits
null for identities that are explicitly absent from the proof, while
tokenBalances (function tokenBalances) omits absent identities from the Map;
make the comment adjacent to the balances signature or its return handling so
future maintainers don't change one to match the other.
8fd23ff to
9814fcd
Compare
|
CI failure analysis: the red check is |
| #[wasm_bindgen(js_name = "getAddressInfo")] | ||
| #[wasm_bindgen( | ||
| js_name = "getAddressInfo", | ||
| unchecked_return_type = "PlatformAddressInfo | null" |
There was a problem hiding this comment.
You shouldn't use uncheck types in this case. Wasm bindgen gerate proper typeing for you. It uses undefined for optional values which in ideomatic
There was a problem hiding this comment.
@shumkov Thanks for the feedback. I understand — wasm-bindgen uses undefined for optional values and that's the idiomatic JavaScript pattern. So the TS facade return types should stay | undefined rather than converting to | null.
I'll revert the type changes in the JS facades back to | undefined. The original issue was runtime errors when consumers did strict === null checks against what wasm-bindgen returns as undefined — but the right fix is to document that consumers should use nullish checks (== null or ?? fallback), not to change the API contract.
Will update the PR.
There was a problem hiding this comment.
Done — removed all 85 unchecked_return_type annotations across 16 files. wasm-bindgen now generates types natively (Option<T> → T | undefined, etc.). Force-pushed with a clean rebase on v3.1-dev.
84c332a to
00545f9
Compare
|
Reworked per shumkov's review feedback (review #3): What changed: Force-pushed to a single commit. The previous 6 commits that changed What remains: The only change is in Per shumkov's feedback:
1 file changed, 10 insertions, 3 deletions. |
Let wasm-bindgen generate proper TypeScript typing natively. For Option<T> returns, wasm-bindgen uses `undefined` which is idiomatic JavaScript/TypeScript. Requested-by: shumkov
00545f9 to
e3b8e9e
Compare
shumkov
left a comment
There was a problem hiding this comment.
You missunderstood me. I was talking about case whern you don't need it. In this cases you defon need it.
|
@shumkov Thanks for clarifying — I understand now. You're saying wasm-bindgen already generates the correct types for these cases (including The current state of the PR does exactly that: removes all 85 Is the current diff what you had in mind, or are there additional changes you'd like? |
Issue Being Fixed
Addresses review feedback from @shumkov: remove
unchecked_return_typeannotations and let wasm-bindgen generate proper TypeScript typing natively.Description
Removes all 85
unchecked_return_typeannotations from wasm-sdk query methods. wasm-bindgen generates proper TypeScript types automatically:Option<T>→T | undefined(idiomatic JS/TS)Map/Array→ standard JS typesThe previous approach overrode wasm-bindgen's type generation with
unchecked_return_typeto provide richer generic types (e.g.,Map<Identifier, bigint>). Per reviewer guidance, the native wasm-bindgen output is preferred.Breaking Changes
TypeScript consumers may see changes in generated
.d.tstypes:| nulloverride now correctly show| undefinedfor optional returnsMap/Arrayreturns are no longer explicitly annotated