-
Notifications
You must be signed in to change notification settings - Fork 2
Description
As per the first version of sub37, the whole architecture expects Adapters always to return a ParseResult, containing data and perhaps some ParseError.
The idea was to have ParseResult and ParseError exposed by the BaseAdapter so that every adapter could use them without importing anything else and without making @sub37/server export other material.
However, the current situation reveals itself to be somehow inconsistent:
-
BaseAdapter/index.tsexportsBaseAdapter(default),ParseResult, andParseErrorclasses. We should technically moveParse*to a different file; -
BaseAdapterexposesParseResultas an instance property, but notParseError; -
Related to the points above, tests and WebVTT adapter use
ParseResultfrom there, whileBaseAdaptershould have been the entry point to access them.
This happens becauseBaseAdapter.ParseResultis actually a method that returns anew ParseResultand, therefore it cannot be used as right-hand in aninstanceofcomparison: we must useinstanceof ParseResult, but we should useinstanceof BaseAdapter.ParseResult; -
BaseAdapterexposes bothParseResultandParseErrortypes by using a namespace; -
ParseErrorclass is exposed fromBaseAdapter/index.tsmodule, but it is not used as a class (this happens due to the point 3, so it is an useless class.
Fixing the whole situation is quite breaking, so should be fixed in the next major.