#How to default export an object of an interface type in TS
53 messages · Page 1 of 1 (latest)
since you're using ts, you should be using esm-like syntax
ik how to do that
cjs imports/exports will be generated upon compilation
but how do I make the type of my interface type
like make module.exports Command type
you don't really need to do that
ts is structurally typed
you could do one of these
const command: Command = { ... };
export default command;
``````ts
export default { ... } satisfies Command;
I have seen the first one
long but could work
but what is the second one?
satisfies?
it's relatively new
ah
should I use 1 or 2 then?
up to you
since 2 is newer I assume 1
what pattern do you like more
ahhhh
tbh the second one is short but confusing
not really a concern with ts, since compatibility isn't a big concern with devDependencies
but the first one is simple but longer
i don't think it's really confusing, satisfies is really useful
i'd guess it's just confusing now since that's new to you
but again, up to you
if you prefer the former, go ahead
oh I see
I want to hear what you would recommed
since I want this to go into a repo
i wouldn't recommend either over the other without context tbh
i personally would use a class
for commands?
yeah
this is what I am using it for
that's specific to me though, i use java as well so the patterns leak through in my mind
I tried the class I spent days writing classes and got no where
same
but since I started using TS I realized there are faster ways
i have a public repo that i use for bots that kinda has a framework (im working on separating out the framework, but i haven't had time)
you could try checking that out if you want to use classes
oooh
only other thing i can really recommend you is the ts server for more opinions
could you send a link?
I already am in so many servers
besides for me this is a very nitty gritty scenario
like I have never had such specific things needed
https://github.com/That-Guy977/bots-archive/tree/ts
development has slowed down a lot so some stuff might not be up to spec
i don't have enough free time lmao
oh ok
relatable
(both the repos that are referenced in the main readme are currently local, those will yield 404s)