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

Enum will help with problems #159

Open
cesarjhony opened this issue Aug 2, 2019 · 3 comments
Open

Enum will help with problems #159

cesarjhony opened this issue Aug 2, 2019 · 3 comments

Comments

@cesarjhony
Copy link

I dispend many of time searching bugs in my code, and when I found was a problem like:
pin.writeSync(true); //not work
pin.writeSync(1); //work fine
pin.writeSync(Gpio.HIGH); //work fine, but ENUM is not a Standard in your lib.
But, I and the most of devs use autocomplete, like a VS Code. With the STATIC or ENUM constants might save the day, the assistents find there and show us the options.
Please add all options like a static.
Your framework is amazing, but it still may be better.

@fivdi
Copy link
Owner

fivdi commented Aug 11, 2019

@cesarjhony Thank you for suggesting this improvement. I'll take a look to see what can be done to improve things.

@johntalton
Copy link
Contributor

Ive used HIGH / LOW in my work, as exported here:

onoff/onoff.js

Line 343 in 07d36e2

Gpio.HIGH = HIGH;

while the TS version does something a bit different:

export type High = 1;

I would suggest that the js->d.ts is a stub solution at this point and there the BinaryValue type exists.

Anything to aid in the correctness / clearness / ease of use would be interesting as many libraries "export" this type of const FOO = x / Klazz.FOO = FOO style pattern. @cesarjhony Could you expand on your desired Use Case?

@cesarjhony
Copy link
Author

My usage was just:
HIGH, LOW, IN, OUT;

I don't know if will better to be grouped style like:
Gpio.Level={ HIGH, LOW };
Gpio.Direction={ OUT, IN };

Thank you very much for appreciate my opinion 😊, but I have no better ideas.

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

No branches or pull requests

3 participants