JustFly1984 / react-google-maps-api

React Google Maps API
MIT License
1.75k stars 426 forks source link

Set `boxStyles` type to Partial<CSSStyleDeclaration> #3263

Closed HerrBertling closed 11 months ago

HerrBertling commented 12 months ago

Issue template

Please provide an explanation of the issue

As lined out in https://github.com/JustFly1984/react-google-maps-api/pull/3260#pullrequestreview-1535328776, I think the type for boxStyle is not correct. Here's the location in the code

In our project, there's an InfoBox with boxStyles applied. Since the latest update, I'm getting a TS error that

Type '{ padding: string; width: string; }' is missing the following properties from type 'CSSStyleDeclaration': accentColor, alignContent, alignItems, alignSelf, and 476 more.

And while I'm quite fond of the opportunity to test my knowledge of all the CSS style declarations, I guess this could be resolved in an easier way by turning the type from boxStyle?: CSSStyleDeclaration | undefined; to boxStyle?: Partial<CSSStyleDeclaration> | undefined; 😄

Your Environment

os: mac

node --version 16.14.2

react version 18

webpack version – using Vite

@babel version doesn't matter 😊

@react-google-maps/api version 2.19.1

How does it behave?

As described, getting a type error.

How should it behave correctly?

As described, boxStyle should use Partial<> to allow some CSSStyleDeclaration and not ask for ALL of them.