Moves displayName, names, extension to external consts in each TargetLanguage file, and then passed as a generic arg to the base TargetLanguage class. This allows them to be statically analysed by the TypeScript compiler - leading to stricter typings for languages.
TypeScriptFlowBaseTargetLanguage has been removed
TypeScriptTargetLanguage and FlowTargetLanguage no longer extend from JavaScriptTargetLanguage
all TargetLanguage classes now inherit directly from TargetLanguage instead*
*this is a minor breaking change for anyone who was inheriting from an existing TargetLanguage class, guide on how to properly extend custom classes to come
Motivation and Context
Previously, the lang option would allow for string | TargetLanguage - which would allow for any arbitrary string to be passed and would cause errors at runtime instead of at write time. This change shifts that error left and prevents any incorrect strings from being passed in the first place.
Description
Moves
displayName
,names
,extension
to external consts in eachTargetLanguage
file, and then passed as a generic arg to the baseTargetLanguage
class. This allows them to be statically analysed by the TypeScript compiler - leading to stricter typings for languages.TypeScriptFlowBaseTargetLanguage
has been removedTypeScriptTargetLanguage
andFlowTargetLanguage
no longer extend fromJavaScriptTargetLanguage
TargetLanguage
classes now inherit directly fromTargetLanguage
instead**this is a minor breaking change for anyone who was inheriting from an existing
TargetLanguage
class, guide on how to properly extend custom classes to comeMotivation and Context
Previously, the
lang
option would allow forstring | TargetLanguage
- which would allow for any arbitrary string to be passed and would cause errors at runtime instead of at write time. This change shifts that error left and prevents any incorrect strings from being passed in the first place.Previous Behaviour / Output
options.lang
used to be:New Behaviour / Output
now looks like:![image](https://github.com/glideapps/quicktype/assets/10782902/6119375d-4300-4cdb-abd0-dbcfba704078)
How Has This Been Tested?
Screenshots (if appropriate):