dao-xyz / borsh-ts

⚡️fast TypeScript implementation of Borsh serialization format
Apache License 2.0
37 stars 2 forks source link

Checking Type number v.s. Array #21

Open hanakannzashi opened 1 year ago

hanakannzashi commented 1 year ago

Currently follow code will succeeded without throwing an error

class Test extends AssignableStruct {
  @field({ type: 'u32' })
  declare arr: string[]
}

async function main() {
  const buffer = serialize(new Test({ arr: ['hello', 'world'] }))
  console.log(buffer)
  const data = deserialize(buffer, Test)
  console.log(data)
}
<Buffer 00 00 00 00>
Test { arr: 0 }

Expected: throw an error

marcus-pousette commented 1 year ago

Thanks for creating this issue. Will look into this.