mapbox / mapbox/mapbox-gl-js

Either treat Value as a top type, or remove Color from its member types

Open
#5,296 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cross-platform :tv:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

https://github.com/mapbox/mapbox-gl-js/blob/816fc155e763f24b6ca77658cb02e64ad9a69309/src/style-spec/function/types.js#L84-L90

According to this logic, together with Array subtyping, Value is effectively the top type.

Since we'll likely soon be adding an array-constructing expression like [make-array, item1, item2, ...], it will be possible for arrays to contain colors. Given that, we should:

  • Just treat Value as a true top type (so that checkSubtype(ValueType, t) always succeeds)
  • Remove Color from the member types of Value. Doing this would also imply:
    • Change the base Array type to mean Array<Any> rather than Array<Value>
    • Change the Value member Array to Array<Value>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/style-spec/function/types.js lines 84-90 and trace the existing Value, Color, Array, and checkSubtype logic. Compare the two proposed type-system options, then verify that the chosen semantics consistently handle array subtyping and Value's member types.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.