Typescript declaration merging to expand or override module type or interface property Typescript declaration merging to expand or override module type or interface property typescript typescript

Typescript declaration merging to expand or override module type or interface property


This might not be the solution you're looking for but I usually have a custom interface for location (maybe export it from a shared .ts file on your app), then use useLocation hook with that interface.

import React, { ReactElement } from "react";import { useLocation } from "react-router-dom";interface CustomLocationState {    A: string;    B: string;}export default ():ReactElement => {    const { state: {A, B} } = useLocation<CustomLocationState>();    return <div>{A} - {B}</div>}