Skip to content

Type-safety gap: StreamBuilder.build()'s return type claims ratePerSecond is always a string, but a number input stays a number at runtime #459

Description

@Jaydbrown

StreamBuilder.ratePerSecond(val: number | bigint) (src/builder.ts) accepts either a number or a bigint. build() runs the config through bigintSafeStringify(), which only converts values whose typeof is 'bigint' to strings — a plain number value passes through unchanged. But build()'s return is force-cast with as { ...; ratePerSecond?: string }, so calling .ratePerSecond(500).build() (a valid call per the method's own signature) produces an object whose ratePerSecond is the runtime number 500, while the TypeScript type asserts it's a string. Any caller trusting the declared type (e.g. doing .trim() or string concatenation on it) hits a runtime error TypeScript can't catch.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions