Impact: low. Compile-time error, so it fails loudly. Only affects consumers on TS 5.7+ who pass SDK bytes to a BufferSource parameter, and the workaround is a one-line copy.
Problem
Byte fields are typed plain Uint8Array, i.e. Uint8Array<ArrayBufferLike>, which TS 5.7+ lib defs reject wherever BufferSource is required.
Verified on 17.0.0
tsc --strict with lib: ["ES2022", "DOM"]:
declare const e: xdr.ContractCodeEntry;
WebAssembly.compile(e.code);
TS2345: Argument of type 'Uint8Array<ArrayBufferLike>' is not assignable to
parameter of type 'BufferSource'.
Type 'ArrayBufferLike' is not assignable to type 'ArrayBuffer'.
Type 'SharedArrayBuffer' is not assignable to type 'ArrayBuffer'.
Freighter worked around it with a new Uint8Array(...) copy.
Proposed fix
Type byte fields as Uint8Array<ArrayBuffer>. This is a narrowing, so it is non-breaking for consumers, but it ripples across every byte-returning signature in the XDR codegen — worth sizing before committing.
Also absent from all three migration guides; a line in the Uint8Array guide would cover consumers until the types change.
Reported by @aristidesstaffieri from the Freighter v17 migration (stellar/freighter#2977).
Impact: low. Compile-time error, so it fails loudly. Only affects consumers on TS 5.7+ who pass SDK bytes to a
BufferSourceparameter, and the workaround is a one-line copy.Problem
Byte fields are typed plain
Uint8Array, i.e.Uint8Array<ArrayBufferLike>, which TS 5.7+ lib defs reject whereverBufferSourceis required.Verified on 17.0.0
tsc --strictwithlib: ["ES2022", "DOM"]:Freighter worked around it with a
new Uint8Array(...)copy.Proposed fix
Type byte fields as
Uint8Array<ArrayBuffer>. This is a narrowing, so it is non-breaking for consumers, but it ripples across every byte-returning signature in the XDR codegen — worth sizing before committing.Also absent from all three migration guides; a line in the Uint8Array guide would cover consumers until the types change.
Reported by @aristidesstaffieri from the Freighter v17 migration (stellar/freighter#2977).