-
-
Notifications
You must be signed in to change notification settings - Fork 23.3k
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: add initial typescript migration #2108
base: master
Are you sure you want to change the base?
Conversation
This commit performs the base changes that are needed to migrate the codebase to typescript.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Btw we shouldn't bundle the code, Vercel supports TS out of the box. |
Your right. That's why I closed #2104. Here I use babel for the tests, not for the deployment. Is this also not needed? github-readme-stats/babel.config.js Lines 1 to 6 in bcda6ce
|
Oh cool then. |
* Add types for common directory * Reflect the code reviews * style: improve syntax * style: improve typescript syntax Co-authored-by: rickstaa <rick.staa@outlook.com>
class Card { | ||
/** Card colors. */ | ||
export interface CardColors { | ||
/** Title color. */ |
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.
All these comments are quite repetitive, the property itself is very self explanetory.
@@ -10,7 +81,7 @@ class Card { | |||
* @param {string?=} args.customTitle | |||
* @param {string?=} args.defaultTitle | |||
* @param {string?=} args.titlePrefixIcon | |||
* @param {ReturnType<import('../common/utils.js').getCardColors>?=} args.colors | |||
* @param {ReturnType<import('./utils').getCardColors>?=} args.colors |
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 should remove jsdoc type defs if we are using TS.
@@ -1,4 +1,7 @@ | |||
const icons = { | |||
|
|||
export type Icons = {[key: string]: string}; |
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.
Just use a Record<string, string>
|
||
/** | ||
* @param {string} message | ||
* @param {string} secondaryMessage | ||
* @returns {string} | ||
*/ | ||
const renderError = (message, secondaryMessage = "") => { | ||
const renderError = (message: string, secondaryMessage = "") => { |
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 set message to string but we didn't set secondaryMessage to string. In parameters we should be explicit about the types.
super(message); | ||
this.type = type; | ||
this.secondaryMessage = SECONDARY_ERROR_MESSAGES[type] || type; | ||
} | ||
|
||
static MAX_RETRY = "MAX_RETRY"; | ||
static USER_NOT_FOUND = "USER_NOT_FOUND"; | ||
static MAX_RETRY = "MAX_RETRY" as "MAX_RETRY"; |
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.
as const
doesnt work?
86aafe8
to
8bc69e7
Compare
This commit performs the base changes that are needed to migrate the codebase to typescript. Should be merged after: