Skip to content

How can one implement mostly the same classes #223

Closed Answered by holzensp
foreg asked this question in Q&A
Discussion options

You must be logged in to vote

The default value of a type union is undefined, by default. If you want it to have a default, you have to annotate one of the alternatives with a * (see here).

Since features: FreeFeatures|PaidFeatures has no default value, there is nothing to amend when you say features {. In this case, you should either give it a default value upon its first use (in free.pkl):

features = new FreeFeatures {

of you give it one in the template.pcl:

features: *FreeFeatures|PaidFeatures

Mind you, there is general IDE degradation from using such unions; when I edit free.pkl, autocomplete for the body of features gives me both advertisement and exporter.

Also, why is free.pkl an extends of template.pcl and n…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@foreg
Comment options

Answer selected by foreg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants