Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IS_REO: ReqI property incorrectly typed as just 0 #45

Closed
mkapal opened this issue Jul 28, 2024 · 1 comment · Fixed by #46
Closed

IS_REO: ReqI property incorrectly typed as just 0 #45

mkapal opened this issue Jul 28, 2024 · 1 comment · Fixed by #46
Assignees
Labels

Comments

@mkapal
Copy link
Member

mkapal commented Jul 28, 2024

Problem

In the IS_REO packet, which can be sent and received (both ways), the ReqI property is described as "0 unless this is a reply to an TINY_REO request". In code, it is declared as readonly with the default value of 0, which restricts its type to just 0. This causes issues when trying to compare the received ReqI in the packet event handler, which can be any number.

/** 0 unless this is a reply to an {@link TINY_REO} request */
@byte() readonly ReqI = 0;

Example vent hander in an application:

inSim.on(PacketType.ISP_REO, (packet) => {
  console.log(packet.ReqI === 2);
  //  Error TS2367: This comparison appears to be unintentional because the types 0 and 2 have no overlap.
});

Solution

Remove the readonly modifier from ReqI declaration, which will widen its type to number.

Copy link

🎉 This issue has been resolved in version 4.1.5 🎉

The release is available on:

Your semantic-release bot 📦🚀

@mkapal mkapal removed the bug Something isn't working label Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant