Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix shared views breaking ABI contract
As outlined in #209, the TypeScript runtime utilizes a shared buffer for encoding which can lead to subtle bugs when decoding multiple types. For example: ```typescript // should be the data of 'CreateUser' const createUserBuffer = CreateUser.encode({ email: "[email protected]" }); // encode another type CreateOk.encode({ now: 1 }) // fails to decode as the data of 'createUserBuffer' is now the data of 'CreateOk.encode' const user = CreateUser.decode(createUserBuffer); ``` This change ensures we create and return a new buffer from 'toArray()'; yes, it allocates additional data, but it means users don't need to think about what happens when encoding multiple types when they might still need the data buffer.
- Loading branch information