Feature helpers ts - #1
Conversation
darh
left a comment
There was a problem hiding this comment.
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
| */ | ||
| export class System { | ||
| constructor (ctx = {}) { | ||
| private SystemAPI: SystemAPI; |
There was a problem hiding this comment.
This MUST be set, not optional.
There was a problem hiding this comment.
Should only the API be set or all the ctx params ?
There was a problem hiding this comment.
inspect the code and propose/decide :)
There was a problem hiding this comment.
The API and namespace params are required. Everything else is optional.
There was a problem hiding this comment.
Scratch that, namespace is optional too.
| private $channel?: Channel; | ||
| private $message?: Message; | ||
|
|
||
| constructor (ctx: Context) { |
There was a problem hiding this comment.
You could replace Context with Partial<Messaging>
https://www.typescriptlang.org/docs/handbook/utility-types.html#partialt
There was a problem hiding this comment.
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.
What did you try and what does not work?
There was a problem hiding this comment.
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
| } | ||
|
|
||
| interface ChannelResponse { | ||
| [_: string]: unknown; |
There was a problem hiding this comment.
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.
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
| private $channel?: Channel; | ||
| private $message?: Message; | ||
|
|
||
| constructor (ctx: Context) { |
There was a problem hiding this comment.
What did you try and what does not work?
c893893 to
4ef8ed8
Compare
4ef8ed8 to
8d55f7f
Compare
Files to be converted to Typescript