Typescript type of MaterialTextfield

Viewed 96

I am creating my first react typescript app. I found a some sample in pure javascript and wan't to write sth similar in typescript.

In firebase javascript sample we can see

addCommentForm.onsubmit = function(e) {
  e.preventDefault();
  createNewComment(postId, firebase.auth().currentUser.displayName, uid, commentInput.value);
  commentInput.value = '';
  commentInput.parentElement.MaterialTextfield.boundUpdateClassesHandler();
};

I would like to do sth similar in typescript, I would like to create a function like below

function resetMaterialTextfield(element: HTMLInputElement) {
  element.value = '';
  element.parentNode.MaterialTextfield.boundUpdateClassesHandler();
}

My question is:

  • How should I declare element, with what type, so that it had parentNode, parentElement attribute, and that parent had MaterialTextfield on which I could call boundUpdateClassesHandler()?

  • From which library/framework does MaterialTextfield come from? What type is it? Where can I find documentation or some tutorial for this class and library?

1 Answers

Use type assertion. (element.parentNode as TypeYouWant).MaterialTextfield.boundUpdateClassesHandler();

Related