I saw this block of code in our code base and I have a bit of a problem to understand void = (page). According to https://stackoverflow.com/a/34274584/513413, the return type is coming after => which is void in my case. So what does = (page) => {} do?
What is its equivalent function if I don't write it with fat arrow function?
This is the code:
private navigateTo: (page: string) => void = (page) => {
// display page
}
You are looking at the code incorrectly. The general structure is
The type is
(page: string) => voidand the value is(page) => {}. The type means thatnavigateTois a function that accepts a string as argument and returns nothing, which is what(page) => {}does.