If you don't specify a type parameter to useState the type of the state will be inferred from the value passed to useState. Since you pass in null, the type of the state will be null, meaning that it can have no other value except null.

You can specify a wider type for the state as a type parameter:

const [intervalData, setIntervalData]:[null | NodeJS.Timeout, (interval: null | NodeJS.Timeout) => void] = useState<null | NodeJS.Timeout>(null);

Playground Link

Note: I would drop the type annotation from the const altogether, but I'm guessing that might have been added just for the example in the question.

Related Query

More Query from same tag