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

Refactor project to Typescript #10

Closed
greenlucid opened this issue Nov 16, 2022 · 1 comment
Closed

Refactor project to Typescript #10

greenlucid opened this issue Nov 16, 2022 · 1 comment

Comments

@greenlucid
Copy link
Contributor

no big export default

export default ({
  hey: "hello"
  hello: "hello",
  test: 10
})

to

interface Thing {
  hello: string
  hey: string
  test: number
}

const thing: Thing = {hello: "hello", hey: "hello", test: 10}

export default thing

why: autocomplete for imports is easier. more tidy and easy to refactor. better documented.

refactor react components to typescript

change file extension to .tsx

use React.FC type for components

(this below is a personal preference, but i think it's desirable to avoid duplication) don't decompose props in the arguments of the component.

instead of:

const Animals: React.FC<{dog: string, cat: string, mouse: string}> = ({dog, cat, mouse}) => {
  return (
    <div>
      i hate my dog {dog}, my cat {cat} and my mouse {mouse}
    </div>
  )
}

do

const Animals: React.FC<{dog: string, cat: string, mouse: string}> = (p) => {
  return (
    <div>
      i hate my dog {p.dog}, my cat {p.cat} and my mouse {p.mouse}
    </div>
  )
}

you get autocomplete with the props, and then you don't need to pass duplicate stuff.

@herniadlf
Copy link
Contributor

@greenlucid i've made several advances with this one. I think that i'm missing one or two files that are still in JS, but i want to share w/ you to check if its in the proper direction

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

No branches or pull requests

2 participants