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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Automattic EventTarget detection #222

Closed
cawa-93 opened this issue May 29, 2021 · 1 comment
Closed

Feature Request: Automattic EventTarget detection #222

cawa-93 opened this issue May 29, 2021 · 1 comment
Labels

Comments

@cawa-93
Copy link

cawa-93 commented May 29, 2021

I have simple code in template:

      <a
        href="https://github.com/cawa-93/anime-library/issues/new/choose"
        @click.prevent="openURL($event.target.href)"
      >馃悶 Bug</a>

And I got TS error:

error TS2531: Object is possibly 'null'.
     @click.prevent="openURL($event.target.href)"
                             ~~~~~~~~~~~~~

error TS2339: Property 'href' does not exist on type 'EventTarget'.
     @click.prevent="openURL($event.target.href)"
                                           ~~~~

It would be fantastic if the TS determined that

  1. EventTarget actually is HTMLAnchorElement
  2. It is guaranteed exist

I use vue-tsc with PhpSthorm if this have matter

@johnsoncodehk
Copy link
Member

Event types is upstream problem, it's define in vue-next: https://github.com/vuejs/vue-next/blob/ecd97ee6e465ec5c841d58d96833fece4e899785/packages/runtime-dom/types/jsx.d.ts#L1183-L1297

Please wait for TS support in template: vuejs/core#1359
You can do this after it's supported openURL(($event.target as HTMLAnchorElement).href).

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

No branches or pull requests

2 participants