-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Conversation
Hmm, it doesn't look like anything I did is causing the tests to fail. It's been like that for a while. |
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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') { |
There was a problem hiding this comment.
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.
Addresses rwaldron/johnny-five#1619
You should check this because