You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if the template pulled the extends of keys from TemplateSpecType, instead of from Element.TemplateSpec in the else case.
The reason for this is that you have public properties that are defined in the template based on bound properties.
If we switched to using a setter, we would have to change other locations that used the same bound property, but directly onto Element.TemplateSpec values.
Right now, typescript fails and prevents the usage of the pattern.
/**
* Type used for the return result of _template().
*
* All TemplateSpec properties are made optional. Nested TemplateSpec properties are also made
* optional, except for the `type` propety which is made required.
*/
export type Template<TemplateSpecType extends Element.TemplateSpec = Component.TemplateSpecLoose> = {
[P in keyof TemplateSpecType]?:
P extends ValidRef
?
TemplateSpecType[P] extends Component.Constructor
?
TemplateRequireType<TemplateSpecType[P]>
:
TemplateSpecType[P] extends Element.Constructor
?
Template<InstanceType<TemplateSpecType[P]>['__$type_TemplateSpec']>
:
Template<Element<InlineElement<TemplateSpecType[P]>>['__$type_TemplateSpec']>
:
P extends keyof Element.TemplateSpec
?
TemplateSpecType[P] // P is a Element property key
:
string extends P
?
any // Support Loose Elements: keyof loose Elements `P` will always be a `string`, so let anything go
:
undefined // Otherwise allow the property to only be undefined
};
The text was updated successfully, but these errors were encountered:
This was purposely disallowed because the setters are be executed before any children on the Component have been created and before the Component sub-classes' own constructor is called (which might set up special child accessor properties that might be needed by the setters). Often public setters on Components manipulate the children of the Component and so using them in the _template often results in exceptions because the expected children or properties haven't been created yet.
However the use cause of bindProp() was not considered. I'd rather take this a step further and only allow the special structure that bindProp() produces to be set in this case. What do you think about that?
Absolutely. Just having the bindProp signature would be more than adequate. Otherwise, you should likely be using the constructor or __init, or default properties to achieve it.
It would be nice if the template pulled the extends of keys from
TemplateSpecType
, instead of fromElement.TemplateSpec
in the else case.The reason for this is that you have public properties that are defined in the template based on bound properties.
If we switched to using a setter, we would have to change other locations that used the same bound property, but directly onto
Element.TemplateSpec
values.Right now, typescript fails and prevents the usage of the pattern.
The text was updated successfully, but these errors were encountered: