-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(shared-types): move billing related types to shared folder #2400
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the new organisation a little strange now (i.e. login depending on billing to extend some of the types). Why would LoginBase
be in billing for example? 🤔
I'd think login is a "more fundamental" blocks other modules depend on.
Similar comment for LoginStatistic
being a copy of FormBillingStatistic
I wonder if this indicates there should be a types/login.ts
in the shared folder instead?
src/types/login.ts
Outdated
import { IUserSchema } from './user' | ||
|
||
export interface ILogin { | ||
export interface ILogin extends LoginBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does ILogin
still need to be exported? Looking at the rest of the codebase, it looks like the expectation is to only use ILoginSchema
? (I only see ILogin
being used in test, not in app code)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably stop exporting that; seems like the newer mongoose versions automatically type with a lean version of xxxSchema
types when creating a new document. It used to be the case that we needed a separate typing for creating documents, as xxxSchema
types contain extra props that is not needed to create a new document.
formId: IFormSchema['_id'] | ||
authType: ILoginSchema['authType'] | ||
export interface ILoginSchema extends ILogin, Document { | ||
created?: Date |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By moving created
to ILoginSchema
, is it still optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since this typing is used for document creation, and we don't want to enforce a created
prop to be assigned for document creation.
We should actually create a LoginDocument
typing for the object that is retrieved from the database (with all the defaults populated, and have the optional types converted to required), but there are currently no cases where that is needed and thus not done yet.
5254c6e
to
e40c635
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't mean to be blocking this PR 😱
I think with the comment in billing.ts
, it's probably good enough as is. And we can reorg again later if needed.
Let's go!
Problem
This PR extracts out billing related types to the root shared folder
Related to #2066
Solution
Breaking Changes
Features: