Symbolizers should not take any; should take duck-typed option bags
This would add helpful type and exhaustiveness checking for those writing rules in TypeScript.
Had to revert this as it is too restrictive for function attributes. It is important to let the user distinguish between a function that takes (z,f) vs just (z) - in the 2nd case certain Symbolizers can optimize by doing less context mutating. Getting this to work with the type system is quite a puzzle. Until then function attributes should generally be specified with a full signature like (z:number, f:Feature):string for type safety and exhaustiveness checks.
Possible approach by @nf-s : https://github.com/protomaps/protomaps.js/pull/68#issuecomment-956002443
The current solution is, when writing rules in TypeScript, any attribute function has signature (zoom: number, feature?: Feature).
In terms of library core values, I see two happy paths:
- Via a "traditional" script-includes, with rules written in plain JavaScript. The distinction between
(z,f?)and(z,f)is irrelevant here because the types are gone. - using a bundler,
protomapsas an es6 module dependency with TypeScript. There is a small ergonomics issue - having to use?everywherefis referenced. This annoyance seems like an acceptable tradeoff in the case you care about typing.
closed by https://github.com/protomaps/protomaps-leaflet/commit/bbe8075aa741765b462668a6d9ec47cf111ab766