Content pfp
Content
@
0 reply
0 recast
0 reaction

0xl0wlevelcr0w pfp
0xl0wlevelcr0w
@l0wlevelcr0w
When you guys do typescript, do you make a separate folder for types or just stick em in line in the file?
5 replies
0 recast
4 reactions

Darryl Yeo šŸ› ļø pfp
Darryl Yeo šŸ› ļø
@darrylyeo
Iā€™m a fan of having a ā€œconstantsā€ folder that houses all your common types, enums, and regular JavaScript constants.
0 reply
0 recast
1 reaction

joaofaustino pfp
joaofaustino
@joaofaustino
If used once, keep it in the same file. Promote typing to the directory of a complex feature first and then elevate to the types directory for broader use. Thatā€™s my teamā€™s approach šŸ˜‰
0 reply
0 recast
1 reaction

CyberPnk pfp
CyberPnk
@cyberpnk.eth
As close to where it's used as possible, until inevitably something makes a circular dependency, then I pull it to a common types folder
0 reply
0 recast
1 reaction

ivyroot pfp
ivyroot
@ivyroot
In line for specific stuff like props but in my current project I have a set of types which Iā€™m using like models. Ex: Place, PlaceGroup, PlaceId. No one module owns these really. Iā€™ve found this helps me keep the code organized in my head.
0 reply
0 recast
0 reaction

Drew pfp
Drew
@drewct
Generic types folder to be avoided. Code should always stay as close as it is used. If that's not possible than you have a design issue
0 reply
0 recast
0 reaction

Len pfp
Len
@len-
I almost always have it in the same file. If itā€™s for a component it just makes sense to keep it in one place. If itā€™s part of a library or utility file it can give context when importing elsewhere.
0 reply
0 recast
0 reaction

Francesco ā€“ oss/acc pfp
Francesco ā€“ oss/acc
@fra
Same file, I find `types.ts` silly (we don't have `functions.ts` di we?)
0 reply
0 recast
0 reaction

Sam pfp
Sam
@sams
Collocation is the single most important aspect to keeping your code well structured imo
0 reply
0 recast
0 reaction

Saihajpreet Singh pfp
Saihajpreet Singh
@saihaj
Same file. TSC can generate typings in a new .d.ts but thatā€™s mostly if I am publishing to NPM
0 reply
0 recast
0 reaction