bramus / bramus/react-native-maps-directions
Wrong Type Inference on React Native project in TypeScript: `timePrecision` prop type is wrong
- Dominant language
- JavaScript
- Stars
- 1.3k
- Forks
- 210
- PR merge metrics
- No merged PRs in 30d
Description
### What is happening?
In a ReactNative typescript project, the type inferred for `MapViewDirections` prop named `timePrecison` is `MapViewDirectionsPrecision` which is defined thus;
```
type MapViewDirectionsPrecision =
| "high"
| "low";
```
The accepted values in Google Directions API are `now` and `none`, which match the type declaration for `MapViewDirectionsTimePrecision`
``` export type MapViewDirectionsTimePrecision =
| "now"
| "none";
```
Hence, when `timePrecision` is set to `high` or `low`, it **_incorrectly_** infers it as the right type. However, at runtime, the following error is thrown
```
MapViewDirections Error: Error on GMAPS route request: Invalid request. Invalid 'departure_time' parameter.
```
When when `timePrecision` is set to `now` or `none`, it **_incorrectly_** infers it as the wrong type.
### Expected
The type inferred for `MapViewDirections` prop named `timePrecison` should be `MapViewDirectionsTimePrecision`
``` export type MapViewDirectionsTimePrecision =
| "now"
| "none";
```
Then the right type is manually edited in the types definition file, it infers the type for `timePrecision` **_correctly_**
### Screenshots
#### Correct props labeled as incorrect


#### Incorrect props labeled as correct


#### When the right type is manually edited into the type definition

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.