Property 'name' does not exist on type 'EventTarget' - React + TypeScriptHow do you explicitly set a new property on `window` in TypeScript?Type definition in object literal in TypeScriptThe property 'value' does not exist on value of type 'HTMLElement'TypeScript Objects as Dictionary types as in C#Are strongly-typed functions as parameters possible in TypeScript?Ignore Typescript Errors “property does not exist on value of type”Typescript: Interfaces vs TypesProperty 'value' does not exist on type 'EventTarget'Property 'value' does not exist on type EventTarget in TypeScriptReactjs and Typescript - Property 'select' does not exist on type 'EventTarget'

Short story with a first person narrator in a future where racial conflict had exploded into an all out war

Why do many programmers abstain from using global variables?

Travel to USA with a stuffed puppet

Importance of electrolytic capacitor size

What is the most likely cause of short, quick, and useless reviews?

Typesetting a comma unless before a line break

How do you manage to study and have a balance in your life at the same time?

Is it possible to observe space debris with Binoculars?

Strange formulas that gave rise to Koszul duality

Given a specific computer system, is it possible to estimate the actual precise run time of a piece of Assembly code

To which airspace does the border of two adjacent airspaces belong to?

How does speed affect lift?

Is it rude to ask my opponent to resign an online game when they have a lost endgame?

What does "se jouer" mean here?

Why didn't Thatcher give Hong Kong to Taiwan?

'Hard work never hurt anyone' Why not 'hurts'?

Real-world issues with using an alias

Is it safe for a student to give negative feedback in student evaluations?

If I have an accident, should I file a claim with my car insurance company?

How can I let authenticated users rebuild caches?

The little bee buzzes around the flower garden

If p-value is exactly 1 (1.0000000), what are the confidence interval limits?

Why don't they build airplanes from 3D printer plastic?

One hour 10 min layover in Newark; International -> Domestic connection. Enough time to clear customs?



Property 'name' does not exist on type 'EventTarget' - React + TypeScript


How do you explicitly set a new property on `window` in TypeScript?Type definition in object literal in TypeScriptThe property 'value' does not exist on value of type 'HTMLElement'TypeScript Objects as Dictionary types as in C#Are strongly-typed functions as parameters possible in TypeScript?Ignore Typescript Errors “property does not exist on value of type”Typescript: Interfaces vs TypesProperty 'value' does not exist on type 'EventTarget'Property 'value' does not exist on type EventTarget in TypeScriptReactjs and Typescript - Property 'select' does not exist on type 'EventTarget'






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















this is my code:



<Button
disabled=filter === 'Active'
size='md'
color='primary'
name='Active' // complete = false
onClick=this.handleFilterClick
>
Active
</Button>


on my function handler i get error on the event:



handleFilterClick = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
// continue here
const name = e.target;


it says:



Property 'name' does not exist on type 'EventTarget'.


I also tried:



(e: React.MouseEvent<HTMLInputElement, MouseEvent> & React.MouseEvent<HTMLButtonElement, MouseEvent>) 


what is the event type for button? in javascript, this works, it can accept name but i don't know why not typescript?










share|improve this question
































    0















    this is my code:



    <Button
    disabled=filter === 'Active'
    size='md'
    color='primary'
    name='Active' // complete = false
    onClick=this.handleFilterClick
    >
    Active
    </Button>


    on my function handler i get error on the event:



    handleFilterClick = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
    // continue here
    const name = e.target;


    it says:



    Property 'name' does not exist on type 'EventTarget'.


    I also tried:



    (e: React.MouseEvent<HTMLInputElement, MouseEvent> & React.MouseEvent<HTMLButtonElement, MouseEvent>) 


    what is the event type for button? in javascript, this works, it can accept name but i don't know why not typescript?










    share|improve this question




























      0












      0








      0








      this is my code:



      <Button
      disabled=filter === 'Active'
      size='md'
      color='primary'
      name='Active' // complete = false
      onClick=this.handleFilterClick
      >
      Active
      </Button>


      on my function handler i get error on the event:



      handleFilterClick = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
      // continue here
      const name = e.target;


      it says:



      Property 'name' does not exist on type 'EventTarget'.


      I also tried:



      (e: React.MouseEvent<HTMLInputElement, MouseEvent> & React.MouseEvent<HTMLButtonElement, MouseEvent>) 


      what is the event type for button? in javascript, this works, it can accept name but i don't know why not typescript?










      share|improve this question
















      this is my code:



      <Button
      disabled=filter === 'Active'
      size='md'
      color='primary'
      name='Active' // complete = false
      onClick=this.handleFilterClick
      >
      Active
      </Button>


      on my function handler i get error on the event:



      handleFilterClick = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
      // continue here
      const name = e.target;


      it says:



      Property 'name' does not exist on type 'EventTarget'.


      I also tried:



      (e: React.MouseEvent<HTMLInputElement, MouseEvent> & React.MouseEvent<HTMLButtonElement, MouseEvent>) 


      what is the event type for button? in javascript, this works, it can accept name but i don't know why not typescript?







      reactjs typescript react-tsx






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 28 at 3:39









      Boy With Silver Wings

      6,3682 gold badges10 silver badges39 bronze badges




      6,3682 gold badges10 silver badges39 bronze badges










      asked Mar 28 at 2:46









      i am gpbaculioi am gpbaculio

      1,0244 gold badges16 silver badges35 bronze badges




      1,0244 gold badges16 silver badges35 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          1
















          event.target is the element from which element is dispatched, which necessarily doesn't have to be the HTMLButtonElement defined in the event.



          However, if you use event.currentTarget, you will see that this error goes away:



          const name = event.currentTarget;


          If you have to use event.target itself, you would have to cast the object:



          const name = event.target as HTMLButtonElement;


          From the typings:



          /**
          * currentTarget - a reference to the element on which the event listener is registered.
          *
          * target - a reference to the element from which the event was originally dispatched.
          * This might be a child element to the element on which the event listener is registered.
          * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12239
          */





          share|improve this answer

























          • Agree with using currentTarget. You could also refine event.target rather than casting. if (e.target instanceof HTMLButtonElement) e.target.name;

            – TLadd
            Mar 28 at 3:40











          • @TLadd true, that would be the better way

            – Boy With Silver Wings
            Mar 28 at 3:54










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389447%2fproperty-name-does-not-exist-on-type-eventtarget-react-typescript%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1
















          event.target is the element from which element is dispatched, which necessarily doesn't have to be the HTMLButtonElement defined in the event.



          However, if you use event.currentTarget, you will see that this error goes away:



          const name = event.currentTarget;


          If you have to use event.target itself, you would have to cast the object:



          const name = event.target as HTMLButtonElement;


          From the typings:



          /**
          * currentTarget - a reference to the element on which the event listener is registered.
          *
          * target - a reference to the element from which the event was originally dispatched.
          * This might be a child element to the element on which the event listener is registered.
          * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12239
          */





          share|improve this answer

























          • Agree with using currentTarget. You could also refine event.target rather than casting. if (e.target instanceof HTMLButtonElement) e.target.name;

            – TLadd
            Mar 28 at 3:40











          • @TLadd true, that would be the better way

            – Boy With Silver Wings
            Mar 28 at 3:54















          1
















          event.target is the element from which element is dispatched, which necessarily doesn't have to be the HTMLButtonElement defined in the event.



          However, if you use event.currentTarget, you will see that this error goes away:



          const name = event.currentTarget;


          If you have to use event.target itself, you would have to cast the object:



          const name = event.target as HTMLButtonElement;


          From the typings:



          /**
          * currentTarget - a reference to the element on which the event listener is registered.
          *
          * target - a reference to the element from which the event was originally dispatched.
          * This might be a child element to the element on which the event listener is registered.
          * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12239
          */





          share|improve this answer

























          • Agree with using currentTarget. You could also refine event.target rather than casting. if (e.target instanceof HTMLButtonElement) e.target.name;

            – TLadd
            Mar 28 at 3:40











          • @TLadd true, that would be the better way

            – Boy With Silver Wings
            Mar 28 at 3:54













          1














          1










          1









          event.target is the element from which element is dispatched, which necessarily doesn't have to be the HTMLButtonElement defined in the event.



          However, if you use event.currentTarget, you will see that this error goes away:



          const name = event.currentTarget;


          If you have to use event.target itself, you would have to cast the object:



          const name = event.target as HTMLButtonElement;


          From the typings:



          /**
          * currentTarget - a reference to the element on which the event listener is registered.
          *
          * target - a reference to the element from which the event was originally dispatched.
          * This might be a child element to the element on which the event listener is registered.
          * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12239
          */





          share|improve this answer













          event.target is the element from which element is dispatched, which necessarily doesn't have to be the HTMLButtonElement defined in the event.



          However, if you use event.currentTarget, you will see that this error goes away:



          const name = event.currentTarget;


          If you have to use event.target itself, you would have to cast the object:



          const name = event.target as HTMLButtonElement;


          From the typings:



          /**
          * currentTarget - a reference to the element on which the event listener is registered.
          *
          * target - a reference to the element from which the event was originally dispatched.
          * This might be a child element to the element on which the event listener is registered.
          * If you thought this should be `EventTarget & T`, see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12239
          */






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 28 at 3:36









          Boy With Silver WingsBoy With Silver Wings

          6,3682 gold badges10 silver badges39 bronze badges




          6,3682 gold badges10 silver badges39 bronze badges















          • Agree with using currentTarget. You could also refine event.target rather than casting. if (e.target instanceof HTMLButtonElement) e.target.name;

            – TLadd
            Mar 28 at 3:40











          • @TLadd true, that would be the better way

            – Boy With Silver Wings
            Mar 28 at 3:54

















          • Agree with using currentTarget. You could also refine event.target rather than casting. if (e.target instanceof HTMLButtonElement) e.target.name;

            – TLadd
            Mar 28 at 3:40











          • @TLadd true, that would be the better way

            – Boy With Silver Wings
            Mar 28 at 3:54
















          Agree with using currentTarget. You could also refine event.target rather than casting. if (e.target instanceof HTMLButtonElement) e.target.name;

          – TLadd
          Mar 28 at 3:40





          Agree with using currentTarget. You could also refine event.target rather than casting. if (e.target instanceof HTMLButtonElement) e.target.name;

          – TLadd
          Mar 28 at 3:40













          @TLadd true, that would be the better way

          – Boy With Silver Wings
          Mar 28 at 3:54





          @TLadd true, that would be the better way

          – Boy With Silver Wings
          Mar 28 at 3:54








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55389447%2fproperty-name-does-not-exist-on-type-eventtarget-react-typescript%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

          155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해