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

Add missing i2cWrite signature #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add missing i2cWrite signature #11

wants to merge 1 commit into from

Conversation

dtex
Copy link
Contributor

@dtex dtex commented Sep 8, 2019

Addresses rwaldron/johnny-five#1619

You should check this because

39zbcq

@dtex
Copy link
Contributor Author

dtex commented Sep 8, 2019

Hmm, it doesn't look like anything I did is causing the tests to fail. It's been like that for a while.

Copy link
Owner

@nebrius nebrius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, I'm so far behind on emails, I just now saw this notification.

We can ignore the failing unit test...I need to get that fixed. It's caused by code injected by istanbul into coveralls, or something like that. The code that has a syntax error (causing the tests to fail) is in one of these two.

@@ -571,7 +571,7 @@ export class J5IO extends AbstractIO {
public i2cWrite(address: number, register: number): void;
public i2cWrite(address: number, inBytes: number[]): void;
public i2cWrite(address: number, register: number, inBytes: number[]): void;
public i2cWrite(address: number, registerOrInBytes: number | number[], inBytes?: number[]): void {
public i2cWrite(address: number, registerOrInBytes: number | number[], inBytes?: number | number[]): void {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm, is the new specific signature being called as shown below?

i2cWrite(address: number, register: number, inBytes: number): void;

If so, we'll want to squeeze this line between line 572 and 573. In TypeScript, the last signature without a semicolon following it is a "merged" signature. It's not one that's actually used by calling TypeScript code, but it encompasses all of the signatures that end with a semicolon to present the "internal"/vanillaJS meta signature.

@@ -587,6 +587,8 @@ export class J5IO extends AbstractIO {
} else if (Array.isArray(registerOrInBytes)) {
register = undefined;
value = registerOrInBytes;
} else if (typeof inBytes === 'number') {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming that my above interpretation of the signature is correct, I think what we want to do is change line 581 to read:

if (typeof registerOrInBytes === 'number' && (Array.isArray(inBytes) || typeof inBytes === 'number')) {
  if (!Array.isArray(inBytes)) {
    inBytes = [ inBytes ]
  }

and then remove this section. I'm not 100%, but I think we need the first half of the signature check too for this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants