-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom property Accessors linting issues with ts-lint #469
Comments
I had another look at the source code: I think it would be an acceptable solution to not return |
The return value is there merely for convenience, and this could be removed. That said, it seems pretty unfortunate that TypeScript is complaining about this. @justinfagnani Any thoughts? |
I think this is quite convenient as well await el.requestUpdate();
// would become
el.requestUpdate();
await el.updateComplete; or a little bigger example: el.requestUpdate().then(() => {
const text = el.querySelector('div > p > span').innerText;
});
// would become
el.requestUpdate();
await el.updateComplete.then(() =>
const text = this.querySelector('div > p > span').innerText;
}); if possible it would be nice to keep it 🤗 if it's really that big of a problem I think we probably could survive without it 😛 |
@sorvell it isn't TypeScript complaining about this, but a specific TSLint rule. @Christian24 I think that rule is too aggressive to be useful. It's not possible to tell that an "unused" Promise is an error. I'd either turn off the rule completely or disable it on the line that calls |
And I don't think we can break the API at this point. We pretty much have to close this. |
@justinfagnani I do not necessarily agree. I do agree TSLint may be a bit too aggressive here, but the general idea is very valid, because it helps spot all the areas where a promise is returned although one might not expect it (thinking about
This only became an issue after custom accessor wrapping was removed, before this it was so much more convenient. Although it would be the inferior solution, maybe implementing two versions like |
Description
The docs show how to use custom accessors. Since RC3
requestUpdate
has to be called inside of the set accessor. TS-Lint always fails here, because requestUpdate returns a Promise that is never waited for and according to microsoft/TypeScript#14982 cannot be waited for anyway in accessors.It would also be great to have an example in the docs how to achieve something similar with the
@property
decorator. I have figured out that putting the decorator on the getter works fine (see child2.ts in the stackblitz), but is it intended to be that way? I kinda like the idea of doing something similar toattribute
, where you can overwrite the name of the property yourself, so the decorator could be put on the private class variable (that likely also has the initial value).Live Demo
child.ts shows the implementation with
@property
:https://stackblitz.com/edit/lit-element-hello-world-85lc6q?file=child.ts
child2.ts shows the get properties implementation:
https://stackblitz.com/edit/lit-element-hello-world-85lc6q?file=child2.ts
Expected Results
No linting issue when using custom accessors. Documentation on how to implement custom accessors with
@property
decorator.Actual Results
linting issue with custom accessors.
Versions
The text was updated successfully, but these errors were encountered: