Open zakjan opened 8 years ago
@MeirionHughes, currently this issue is assigned to 0.11 milestone, but i think that this issue has actually the most impact for this project (mostly for newcomers, but it could have saved some of my time as well last week because of copy-past from camelCaseProperty that should have been converted to kebab-case when used as attribute)
Unfortunately, the rework stuff is slow going (0.10) as its taken a while to decide how to structure it --I'm favoring chain-of-responsiblity style for the rules that operate on the ast - thus abstracting away the parser entirely.
So... I will take a look at this to see if something can be done asap.
Am I correct that currently the missing prerequisite for this task is ability to check/resolve references to other files via <require from="..."
?
So probably a components that would
would be smth in the beginning of the responsiblity chain? Is that smth You have in mind?
Yeah something like that; basically you pass the file result along and they add extra processed data to the result/ast. not entirely there yet. the idea is to make it generic enough so I can throw any file type at the chain.
However, for now, I could probably to grab the source when <require from='./item''
comes up. see if there the first export has the custom element decorator, define a custom element resource, and finally, attach the resource to the ast. that should allow me to check the bindables at least exist and get the type reflection for both the left and right side.
One thing I need to workout is how to get typescript to determine if one type can be assigned to another.
I created a checklist (containing two ideas from @zakjan, one from @zakjan and added couple from myself):
<require from="./does/not/exist"></require>
<item notCorrect.bind="existing"></item>
vs <item is-correct.bind="existing"></item>
( subset of next check, but might be easier to implement, so I added it separately )<item missing.bind="existing"></item>
<item some-number.bind="someString"></item>
Another idea: If --strictNullCheck
is enabled, it could also check if all required bindable attributes are passed, meaning only those explicitly typed with X | undefined
or with a default value could be left unassigned.
okay-doky, I've added something basic (bit ugly too). its limited to './foo' having a first class with FooSomeThingCustomElement and the resulting element being foo-some-thing
. also if you bind to the DOM parts of the element, it will complain at the moment. Will need a way to figure out how to get the reflection information for the base dom element.
More ideas:
value.bind="..."
binding syntax should be required, only string attributes should allow passing value with value="..."
@bindable value: ... | undefined
) can be omitted, otherwise they are required.
item.ts
item.html
page.ts
page.html
This should throw two errors, the first for missing bindable title attribute in ItemCustomElement, the second for mismatching type of value attribute.