You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
As a user of Openlayers with TypeScript, I want to be able to receive feature properties by passing a type as generic.
This allows to explicitly set the type of feature properties for further processing.
Describe the solution you'd like
Current Behavior:
conststop=feature?.getProperties()asStop
Solution i'd like:
conststop=feature?.getProperties<Stop>()
The text was updated successfully, but these errors were encountered:
with this change it's possible to pass a generic type `T` when calling `feature.getProperties<T>()` and using with TypeScript.
```
// before: const stop = feature?.getProperties() as Stop
const stop = feature?.getProperties<Stop>()
console.log(typeof stop) // "Stop"
```
closesopenlayers#14868
with this change it's possible to infer the type `T` of passed properties when calling `feature.getProperties()` and using with TypeScript.
```ts
type Vehicle = {
type: 'Car' | 'Bike' | 'Truck',
color: string
}
const car: Vehicle = { type: 'Car', color: 'Red' }
// Before the change
const feature = new RenderFeature(car);
const properties = feature.getProperties();
// properties inferred as Object<string, *>
// After the change
const feature = new RenderFeature(car);
const properties = feature.getProperties();
// properties inferred as Vehicle
```
closesopenlayers#14868
Is your feature request related to a problem? Please describe.
As a user of Openlayers with TypeScript, I want to be able to receive
feature
properties by passing a type as generic.This allows to explicitly set the type of feature properties for further processing.
Describe the solution you'd like
Current Behavior:
Solution i'd like:
The text was updated successfully, but these errors were encountered: