-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
refactor: refactor types #249
Conversation
Pull Request Test Coverage Report for Build 8925325272Details
💛 - Coveralls |
src/schema.ts
Outdated
@@ -379,7 +380,7 @@ class QueryParser { | |||
} | |||
|
|||
|
|||
class Schema { | |||
class Schema<T> { | |||
paths: Record<string, SchemaType<any>> = {}; | |||
statics: Record<string, (...args: any[]) => any> = {}; |
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.
statics: Record<string, (...args: any[]) => any> = {}; | |
statics: Record<string, (this: T, ...args: any[]) => any> = {}; |
Is it possible to improve the types here as well? This could achieve stricter type checking.
src/database.ts
Outdated
@@ -118,7 +118,7 @@ class Database { | |||
* @param {Schema|object} [schema] | |||
* @return {Model} | |||
*/ | |||
model(name: string, schema?: Schema | Record<string, AddSchemaTypeOptions>): Model<any> { | |||
model<T>(name: string, schema?: Schema<T> | Record<string, AddSchemaTypeOptions>): Model<any> { |
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.
model<T>(name: string, schema?: Schema<T> | Record<string, AddSchemaTypeOptions>): Model<any> { | |
model<T = any>(name: string, schema?: Schema<T> | Record<string, AddSchemaTypeOptions>): Model<any> { |
We can assign a default value to any
to prevent breaking change (where model previously doesn't require a type argument).
In fact, the Line 12 in 2c89f53
|
check list
Description
ref: hexojs/hexo#5483 (comment)
Additional information
How to use it now:
virtual
static