I use Typescript for my application and I want to use FeatureLayerProperties to ensure whatever is put through the function, meets the bare minimum requirement for a FeatureLayer for purposes of creation.
Currently I am using a parameter:any, because paramenter:FeatureLayerProperties doesn't work, as FeatureLayerProperties is not exported by any arcgis library I have found so far.
Is there a way to expose FeatureLayerProperties to custom functions/methods/classes so that we can have strongly typed?
You can use some TS utilities to help you out here.
type FeatureLayerProp = InstanceType<typeof FeatureLayer>;
Thanks @ReneRubalcava i actually tried that as fallback option way back but it broke a few times during runtime and stopped that using it.
As far as I know that the FeatureLayerProperties interface is not exported by any ArcGIS library, hence, it cannot be used directly in TypeScript code. However, one workaround way to obtain strong typing is to create a custom interface that extends the FeatureLayerProperties interface and includes any additional properties or restrictions that you require for your specific use case. This custom interface can then be used as the type for your function parameter.
TypeScript: Documentation - Object Types (typescriptlang.org)
As you mentioned it is not exported, so you can't build a customer interface that extends unless it is in the file itself where FeatureLayerProperties sits. Which would get overwritten the minute you updated the arcgis sdk, then you back to square one.
Or are you implying another approach that i didn't see in that link?