[Suggestion] Change `ResourceStoreContext` to use an interface instead of type so consumers can do declaration merging
AllySummers opened this issue · 2 comments
When using react-resource-router, it would be great if the following:
export declare type ResourceStoreContext = any;
could be replaced with:
export declare interface ResourceStoreContext {}
So that consumers of the library can do this to declare a context type and get type information in TypeScript:
// react-resource-router.d.ts
import 'react-resource-router';
import type { MyResourceContext } from './my-resource-context';
declare module 'react-resource-rute' {
export interface ResourceStoreContext extends MyResourceContext {}
}
This is similar to what styled-components does with their global theme: https://styled-components.com/docs/api#create-a-declarations-file
Unfortunately it cannot be done (as far as I am aware) when using a type
, so changing to an interface
would be greatly appreciated :)
Edit: It actually seems the issue is using any
, not type vs interface.
It seems this would fix the problem:
export declare type ResourceStoreContext = {}; // ignore
Edit 2: 99% sure I was actually right the first time, it has to be an interface not a type. Sorry about the confusion!
Should be fine, are you happy to raise a PR for it?
@albertogasparin just realised i meant react resource router, not sweet state 🤦♀️