Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions lcd.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
declare module 'lcd' {
import { EventEmitter } from 'events';
export default class Lcd extends EventEmitter {
constructor(args: {
Copy link
Owner

Choose a reason for hiding this comment

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

Can args be renamed to config so that the naming is the same as the corresponding JavaScript code?

rs: number,
e: number,
data: [number, number, number, number],
cols: number,
Copy link
Owner

Choose a reason for hiding this comment

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

cols is optional and defaults to 16.

rows: number,
Copy link
Owner

Choose a reason for hiding this comment

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

rows is optional and defaults to 1.

});
Copy link
Owner

Choose a reason for hiding this comment

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

The constructor supports an optional largeFont option but this option missing in args above.


print(val: any, cb?: (err: Error, str: string) => void): void;

clear(cb?: (err: Error) => void): void;

home(cb?: (err: Error) => void): void;

setCursor(col: number, row: number): void;

cursor(): void;

noCursor(): void;

blink(): void;

noBlink(): void;

scrollDisplayLeft(): void;

scrollDisplayRight(): void;

leftToRight(): void;

rightToLeft(): void;

autoscroll(): void;

noAutoscroll(): void;

close(): void;
}
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "2.0.5",
"description": "Hitachi HD44780 LCD driver",
"main": "lcd.js",
"types": "lcd.d.ts",
"directories": {
"example": "example",
"test": "test"
Expand All @@ -23,6 +24,7 @@
"mutexify": "^1.2.0"
},
"devDependencies": {
"@types/node": "^11.12.1",
Copy link
Owner

Choose a reason for hiding this comment

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

What purpose does @types/node serve as a dependency. I realize that EventEmitter can be found in @types/node but I don't understand why the @types/node devDependency is needed. At what point will @types/node be used?

Copy link

@daggilli daggilli Nov 16, 2020

Choose a reason for hiding this comment

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

If you are using node core libraries in a Typescript project you need @types/node otherwise nothing will build. But given in this case it is required as a dev dependency, its inclusion is entirely harmless, since it is only being used during development and testing*. End-users can avoid installing dev dependencies by installing a production build.

Really an npm module with pretensions of taking its place in the modern node ecosystem should have typings as a matter of course.

  • unless something in the dependency tree is using it as a mainline dependency, in which case it's going along for the ride willy-nilly. But it's only a few hundred K and you won't see hide nor hair of it in the final transpiled product. It imposes absolutely no runtime penalty whatever.

Choose a reason for hiding this comment

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

Agreed. this looks good.

"async": "^2.6.2",
"jshint": "^2.10.2"
},
Expand Down