Type accepting parameters

30 Views Asked by At

I'm super new to TypeScript & Flow, so maybe I'm asking the wrong question. Here's what I basically want. I have existing code such as follows:

export type MyCustomType = {
 +setCounterActive: boolean => void,
};
import type {MyCustomType} from 'shared/types/custom-type.js'

type Props = {
   ...BaseProps,
   +setCounterActive: boolean,
} 

Now, I want to try to change MyCustomType's setCounterActive to accept two parameters. So I modify it as follows:

export type MyCustomType = {
    +setCounterActive: (loggedIn: boolean, userName: string) => void,
}

How would I modify my Props to adjust to this? Do I need to do something like

import type {MyCustomType} from 'shared/types/custom-type.js'

type Props = {
   ...BaseProps,
   +setCounterActive: (boolean, string)

Then whenever I call setCounterActive I would just pass in a bool and string variable? Thanks.

0

There are 0 best solutions below