Removed assertion for the colors data structure and implemented tests for remaining colors
COLORS type should not be asserted if not explicitly typed in the template or mentioned in the docs
By asserting the structure of the data type this prevents correct solutions from passing the test and restricts developer freedom.
Asserting that colors is an string array makes the following data structure trigger a failure even if the colorCode method produces the correct result;
For reference, OP made the two PRs below in association with the post.
I’m not the TypeScript maintainer, but it’s worth noting that the tests for Resistor Color and almost all other practice exercises come from the upstream problem specifications repo that all 75+ Exercism tracks use to implement an exercise. Are you wanting to make this change specifically for the TypeScript implementation or to the problem specifications repo? The latter would involve a forum discussion and explicit approval from multiple maintainers to proceed with a PR. If it’s just the TypeScript implementation, it’s up to the track maintainers if they want to proceed.
From what I recall, this exercise was initially created as a simple array-focused exercise. Removing the COLORS test completely would remove that focus since there are plenty of ways to solve the exercise without using an array whether you use COLORS in colorCode or not.
Thank you for your post. I also saw the PRs (and added small response).
At the moment we have at least 4 different ways of constructing the COLORS array, so this does not “break the rules”. This set of exercises was written to teach people about arrays, indexing, etc., across multiple tracks.
We will not accept a PR to change this specific exercise to have a looser type. Exporting the known colours is part of the task, and that can only be tested if we limit the type.
The tests do not dictate implementation. You can implement the function internally any way you want. The test dictates that a variable of a specific type exists.
No worries, on the TS track this happens automatically!
We do appreciate you wanting to contribute so please feel free to open another forum post if you want to contribute a change, and feel free to ask here if you have more questions.