Where to declare a types file

Is there a convention to place a types.d.ts file? My project structure looks like this: - client folder and server folder are kept inside the root folder (.git). - These folders have their own package.json and tsconfig.json files. Where should I keep the d.ts files with the type declarations so i can call them directly from client and server components? Can i use the types directly without importing them?
4 Replies
dys 🐙
dys 🐙7mo ago
If you want to share code between projects, you might consider a monorepo that has a package.json (and tsconfig) in the root with a section like:
"workspaces": {
"packages": [
"client/*", "server/*"
]
},
"workspaces": {
"packages": [
"client/*", "server/*"
]
},
Gilfoyle
Gilfoyle7mo ago
so thats what a monorepo is? 💀 also how would i declare types? i still dont understnad from googling 😭
dys 🐙
dys 🐙7mo ago
Honestly, to answer your question, I would dig through MetaGame's Game repo which is the monorepo I have the most experience with. I'd look at the root package.json & tsconfig.json as well as those files in packages/backend/ & packages/web/ which are analogous to your server & client. I don't have time right now.
GitHub
GitHub - MetaFam/TheGame: The platform that MetaGame will be played...
The platform that MetaGame will be played on aka MetaOS - an open source framework for running decentralized societies. Currently featuring MyMeta Profiles, Dashboard & Quests - MetaFam/TheGame
Gilfoyle
Gilfoyle7mo ago
Thanks so much, I'll look through the repo. 👩‍❤️‍💋‍👩
Want results from more Discord servers?
Add your server