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
import{GeoJSONSource,Map}from"mapbox-gl";constmap=newMap({container: document.getElementById("id")!});constsource=map.getSource("id");letgeoJSONSource: GeoJSONSource;if(source?.type==="geojson"){geoJSONSource=source;// <-- this should not be a type error, but it is}
Expected Behavior
You can narrow a Source type to a GeoJSONSource type by using source.type === "geojson".
Actual Behavior
Type 'GeoJSONSource | VideoSource | ImageSource | CanvasSource' is not assignable to type 'GeoJSONSource'.
The text was updated successfully, but these errors were encountered:
Related to #13203
mapbox-gl-js version: v3.5.1
browser: N/A
Steps to Trigger Behavior
type
property of aSource
to narrow its type.Link to Demonstration
https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgcQKYQFIGUDyA5LCAVygGNUAaOAWQEMwBfOAMyghDgCIR6AjCAB4BaAOYAbTgG4AUNNIQAdgGd4PMHAC8cBagDuNegAoE8hTFrAdUAFxwAJhFJEQqMwDoRqGAFExqF2YAQgCeAJJ2hpzAdpwAlACEDLEypipwSsRkqJpwah5ehCTkkdFxMtJ+8J6YuASZ5LZoNfiFWeXAzHCGGUWoAPxuMMFg2RpjXNUAVhkKcYjScItw1dgt9aPp6zIMQA
Repeated here:
Expected Behavior
You can narrow a
Source
type to aGeoJSONSource
type by usingsource.type === "geojson"
.Actual Behavior
Type 'GeoJSONSource | VideoSource | ImageSource | CanvasSource' is not assignable to type 'GeoJSONSource'.
The text was updated successfully, but these errors were encountered: