Skip to content
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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

Conversation

rickstaa
Copy link
Collaborator

@rickstaa rickstaa commented Oct 4, 2022

This commit performs the base changes that are needed to migrate the
codebase to typescript.
@vercel
Copy link

vercel bot commented Oct 4, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
github-readme-stats ✅ Ready (Inspect) Visit Preview Oct 16, 2022 at 8:34AM (UTC)

@anuraghazra
Copy link
Owner

Btw we shouldn't bundle the code, Vercel supports TS out of the box.

@rickstaa
Copy link
Collaborator Author

rickstaa commented Oct 4, 2022

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?

module.exports = {
presets: [
["@babel/preset-env", { targets: { node: "current" } }],
"@babel/preset-typescript",
],
};

@anuraghazra
Copy link
Owner

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. */
Copy link
Owner

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
Copy link
Owner

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};
Copy link
Owner

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 = "") => {
Copy link
Owner

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";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as const doesnt work?

@rickstaa rickstaa mentioned this pull request Dec 3, 2022
3 tasks
@rickstaa rickstaa force-pushed the master branch 2 times, most recently from 86aafe8 to 8bc69e7 Compare January 21, 2023 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants