Closed adamjanicki2 closed 8 months ago
@LeaVerou thoughts on this?
A good design principle for any artifact you develop is the priority of constituencies: End-users > Authors > Implementors > Theoretical purity.
Our convenience is lower priority than our users’ convenience (called "authors" here to distinguish from their own end-users), and their convenience is less important than their end-users’ convenience. Do not inconvenience users to make our life developing or testing easier. Favor internal (implementation) complexity over external (API) complexity.
We should not be making API design decisions based on what TypeScript supports.
The main question is: if a developer has specific-enough needs to want to build their own Node class
It’s not just about making their own Node class; they may not want to treat every object as a node. It's entirely reasonable to want to scope it down to objects that pass certain criteria.
Sure makes sense, let's just stick with plain JS then
@adamjanicki2 Is there any way to tell TS that something is a "Node" without having to define what a node means? It seems like that could give us the best of both worlds.
The best compromise I can think of is setting type Node = any
to provide the flexibility we want while getting good type checking in most other places with other basic typing
Do you think TS still offers us benefits in that case?
Not enough to justify using it over regular JS
Ok, I trust your judgement on this! If you decide to move to TS, I'm game to try it.
One important thing we need to work out before converting this library to TS is how flexible node types are. If they're too flexible, TypeScript becomes useless. For example, we could choose to enforce that nodes have to be objects, or we could allow them to be custom classes. If we allow them to be custom classes and objects, TS isn't going to be much help.
The main question is: if a developer has specific-enough needs to want to build their own Node class, would they even be using Treecle? Are there any common use cases where someone with a non-object type of node would want to use Treecle?