Comments (4)
Typically you can avoid such scenarios by just putting these declarations where they are used and typescript would just pick it up when the file is imported, see here for example: https://github.com/ixahmedxi/orbitkit/blob/main/packages/auth/src/lucia.ts
from orbitkit.
By creating a dedicated types package, you imply that you want to share the same types across all apps and packages. Conceptually that wouldn't be the best practice as you likely use packages differently in different apps. Take a package like Auth.js which relies on a types declaration file (e.g. next-auth.d.ts
) in order to make the user or session object type safe. If you use Auth.js
on both your admin dashboard app and your front-end app, you may not need to share the same properties in the user object for both apps.
For example, in your front-end app, you might want to include an avatar picture and points collected and in your admin dashboard a scope of privileges for what a user can access.
That means that for your front-end app, your declaration file should look like this:
declare module "next-auth" {
interface User {
avatar: string
points: number
}
}
whereas in your admin dashboard app, it should look like this:
declare module "next-auth" {
interface User {
privileges: {
read: boolean
write: boolean
}
}
}
from orbitkit.
Why would you want to declare your own types and share it across the monorepo?
from orbitkit.
types like next-auth types, etc .. check this. I am facing difficult to configure it
from orbitkit.
Related Issues (20)
- Add internationalisation capabilities
- Rate limiting with upstash or unkey
- tRPC api
- Changelog & versioning setup HOT 2
- Create turborepo generators
- Create scripts to remove pieces of orbitkit optionally HOT 5
- create a `packages/hooks` package HOT 3
- Improve README.md documentation.
- Env with a 3rd party HOT 1
- Add security advisory to repo HOT 7
- Migrate to v9 of ESLint and flat config HOT 2
- Add knip integration HOT 1
- Move tsup configuration to use experimentalDts or use rollup
- Unable to start the project on Windows
- Bun support? HOT 2
- If user do not set the public email in github, using login with github will give a 400 error.
- How to use the icons? HOT 2
- Backend support HOT 2
- A CLI HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orbitkit.