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

Typescript #372

Open
songz opened this issue Sep 15, 2021 · 2 comments
Open

Typescript #372

songz opened this issue Sep 15, 2021 · 2 comments
Labels
curriculum enhancement New feature or request js6

Comments

@songz
Copy link
Contributor

songz commented Sep 15, 2021

Goal

This thread is to document what is needed for typescript in our curriculum, so we could make sure our typescript challenge covers what we used in the codebase.

Typescript

  • Need simple input / output types
  • Some function needs to return promises, and define resolved types.
  • Custom types
@songz songz added the js6 label Sep 15, 2021
@Ulisseus
Copy link

Ulisseus commented Sep 20, 2021

Some things which made me confused when I first started using typescript:

  • React.FC
const Foobar:React.FC = ( ) => {....some irrelevant code here}

A generic type which can generate type from another type. Basically, it says that return value of Foobar must be either JSX element or null. And if you provide it another argument const Foobar:React.FC<InputPropsType> it means that input value of Foobar must be of InputPropsType.

  • Long type error messages (the error here is pretty short though):
    TypescriptError
    It would be nice if there were a few examples explaining how to read these messages.
  • Passing types generated by another library as props to another components/types
    const [state, setState] = useState(0)
    It's totally fine to simply copy React.Dispatch<React.SetStateAction<number>> without trying to understand react generics past "it's a state which can hold only numbers'.

Otherwise adding types to pokemon react challenge should be enough IMO.

@anthonykhoa
Copy link
Collaborator

anthonykhoa commented Sep 28, 2021

Typescript specific operators operators should be defined somewhere. I remember looking at some new code in the codebase a few months ago, and had to ask the engineering channel what !. meant.

Here is the code sample I was initially confused about:
https://github.com/garageScript/c0d3-app/blob/master/helpers/updateCache.ts#L43

@SlyBouhafs SlyBouhafs added enhancement New feature or request curriculum labels Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
curriculum enhancement New feature or request js6
Projects
None yet
Development

No branches or pull requests

4 participants