core(tsc): use Config class to define Config type #5525
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously there was the
Config
class (inconfig.js
) and theLH.Config
type (inconfig.d.ts
). TheLH.Config
type implementedLH.Config.Json
, ensuring that anyLH.Config
was also a validLH.Config.Json
.When passing around an instance of
Config
we called it anLH.Config
, which meant the compiler was enforcing that it implemented both interfaces, but that means two sources of truth for what a "Config" is and indirect errors if those interfaces were violated.Based on @patrickhulce's idea in #5451 to enforce interfaces until tsc supports
@implements
tags, we can eliminate thed.ts
declaration ofLH.Config
and just use theConfig
class directly, just asserting that the object is a validLH.Config.Json
near the end of the constructor in a throwaway variable.(the rest of the config interfaces staying separate for now because
@typedef
doesn't support inheritance yet 🙄 and they aren't clearly defined anywhere with a constructor or single object literal)