Open songz opened 2 years ago
Some things which made me confused when I first started using typescript:
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.
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.
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
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