-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix typechecking (#1798) #2250
Fix typechecking (#1798) #2250
Conversation
That does not look like the right solution. If you need to make something optional, you add Can you create a project that reproduces your issue? |
It's the same issue as #1798, although happening with plain I'll try to put together a repro 🙏 |
@Pessimistress here's the repro! https://codesandbox.io/p/sandbox/wispy-thunder-tx58mq Run |
No, it's not the same fix. You need to change it where MapRef is used, not where it is defined. Looks like TypeScript compiler is not inferring the return type of --- a/src/components/use-map.tsx
+++ b/src/components/use-map.tsx
@@ -52,7 +52,10 @@ export const MapProvider: React.FC<{children?: React.ReactNode}> = props => {
);
};
-export function useMap<MapT extends MapInstance>() {
+export function useMap<MapT extends MapInstance>(): {
+ [id: string]: MapRef<MapT> | undefined;
+ current?: MapRef<MapT>;
+} {
const maps = useContext(MountedMapsContext)?.maps;
const currentMap = useContext(MapContext); |
@Pessimistress It kind of makes sense, but I don't think I know how to test this kind of change in this repo. Would you mind fixing this yourself the way you suggested? 🙏 EDIT: I implemented the fix, in case you are 100% sure and would like to just merge it |
eeba807
to
297c83a
Compare
297c83a
to
2aa69e0
Compare
@Pessimistress thanks for the merge! Any chance for a new release with this fix? |
Fixes a resurgence of the bug found in #1798
It might be a breaking change because it forces code like this:
to become: