-
Notifications
You must be signed in to change notification settings - Fork 25
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
fix: projects might have strictPropertyInitialization set to true #329
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,18 +25,9 @@ export interface AbstractDataType<T> { | |
*/ | ||
|
||
export abstract class DataType { | ||
dataType: string; | ||
dataType: string = ''; | ||
dataLength?: string | number; | ||
|
||
/** | ||
* Check if params is instance of DataType or not | ||
* @param {*} params | ||
* @returns {boolean} | ||
*/ | ||
static is(params: any): boolean { | ||
return params instanceof DataType; | ||
} | ||
|
||
/** | ||
* cast raw data returned from data packet into js type | ||
*/ | ||
|
@@ -51,21 +42,7 @@ export abstract class DataType { | |
return value; | ||
} | ||
|
||
static get invokable() { | ||
return new Proxy(this, { | ||
get(target, p) { | ||
const value = target[p]; | ||
if (AllDataTypes.hasOwnProperty(p)) return invokableFunc(value); | ||
return value; | ||
} | ||
}); | ||
} | ||
|
||
abstract toSqlString(): string; | ||
|
||
static toSqlString(): string { | ||
return ''; | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -507,7 +484,7 @@ const AllDataTypes = { | |
|
||
type DATA_TYPE<T> = AbstractDataType<T> & T; | ||
|
||
export class DataTypes extends DataType { | ||
class DataTypes { | ||
static STRING: DATA_TYPE<STRING> = STRING as any; | ||
static TINYINT: DATA_TYPE<TINYINT> = TINYINT as any; | ||
static SMALLINT: DATA_TYPE<SMALLINT> = SMALLINT as any; | ||
|
@@ -598,8 +575,23 @@ export class DataTypes extends DataType { | |
} | ||
} | ||
|
||
toSqlString(): string { | ||
return ''; | ||
static get invokable() { | ||
return new Proxy(this, { | ||
get(target, p) { | ||
const value = target[p]; | ||
if (AllDataTypes.hasOwnProperty(p)) return invokableFunc(value); | ||
return value; | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* Check if params is instance of DataType or not | ||
* @param {*} params | ||
* @returns {boolean} | ||
*/ | ||
static is(params: any): boolean { | ||
return params instanceof DataType; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. further refactor the default export existing code that relies on |
||
} | ||
} | ||
|
||
|
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.
compilerOptions.strictPropertyInitialization
complains about unset class fieldThere 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.
which is quite common in our test models, such as
added a default value to make downstream projects happy for now