Skip to content
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

Adding external validators to TextInput #4

Closed
wants to merge 2 commits into from
Closed

Conversation

SweetDealer
Copy link
Contributor

No description provided.

@@ -49,7 +46,7 @@ export default class EditText extends HTMLElement {

/** @param {InputValidator} validator */
addExternalValidator(validator) {
Copy link
Member

@ctapobep ctapobep Apr 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just "validator", it's not "external"

@@ -23,6 +23,9 @@ export default class TextInput extends HTMLElement {
};
/** @type {string} */
#lastChangedValue;
// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because in another case, we need to make an unused import of this component. And if we don’t do this, we get an error

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. What kind of error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS2304: Cannot find name 'InputValidator'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, you need to put this explanation whenever you add some "ignore".

So the problem is that JS Doc doesn't know what type we're referencing without an import - it doesn't know where this type is coming from. But there seems to be a solution to this problem: https://stackoverflow.com/questions/51982814/reference-definition-from-ts-check-js-file

@@ -23,6 +23,9 @@ export default class TextInput extends HTMLElement {
};
/** @type {string} */
#lastChangedValue;
// @ts-ignore
/** @type {InputValidator} */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be an array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants