-
Notifications
You must be signed in to change notification settings - Fork 33
Conversation
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.
This needs some love.
Plus -- please spend some time studying existing code/functions in this repo (like casters, guards... ) and how they are used.
7fb622e
to
3f35f20
Compare
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.
Good first step, but let's improve it as much as we can.
Please take a look at tsdoc and how can existing (jsdoc) comments be changed
src/corredor/helpers/system.ts
Outdated
|
||
/** | ||
* SystemHelper provides layer over System API and utilities that simplify automation script writing | ||
*/ | ||
export class System { | ||
constructor (ctx = {}) { | ||
private SystemAPI: SystemAPI; |
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.
This MUST be set, not optional.
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.
(same in other helpers)
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.
Should only the API be set or all the ctx params ?
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.
inspect the code and propose/decide :)
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.
The API and namespace params are required. Everything else is optional.
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.
Scratch that, namespace is optional too.
src/corredor/helpers/messaging.ts
Outdated
private $channel?: Channel; | ||
private $message?: Message; | ||
|
||
constructor (ctx: Context) { |
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.
You could replace Context
with Partial<Messaging>
https://www.typescriptlang.org/docs/handbook/utility-types.html#partialt
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.
I've tried to do this, but i can't get it working. Looked at other code using Partial and tried it that way. No luck.
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.
What did you try and what does not work?
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.
Partial sets all the props to optional, so that isn't too good since we want the API to be set.
3f35f20
to
a9bd7c4
Compare
434dc30
to
1306840
Compare
Theres still an error in messaging.ts helper on line 85. Casting to new Message() doesn't yet work, because the type isnt done yet. The line is commented for now. |
1306840
to
c893893
Compare
src/corredor/helpers/messaging.ts
Outdated
} | ||
|
||
interface ChannelResponse { | ||
[_: string]: unknown; |
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.
Is this [string]:unknown
really needed?
channel response (as well as any other list responses) are always composed of filter+set.
No other arbitrary props.
(applies to other cases here too)
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.
the [_:string]: unknown in all the responses is there so i dont have to convert from API response to unknown to Channel Response(res as unknown as ChannelResponse). I can instead just do:
res as ChannelResponse
src/corredor/helpers/messaging.ts
Outdated
private $channel?: Channel; | ||
private $message?: Message; | ||
|
||
constructor (ctx: Context) { |
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.
What did you try and what does not work?
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.
almost there.
c893893
to
4ef8ed8
Compare
4ef8ed8
to
8d55f7f
Compare
Files to be converted to Typescript