1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

What Typescript type is a change event? (In Angular)

Discussão em 'Angular' iniciado por Ryan Sperzel, Setembro 8, 2025.

  1. Ryan Sperzel

    Ryan Sperzel Guest

    I'm trying to figure out what Typescript type a change event is used in an Angular project.

    The code is something simple like this:

    file-upload.component.html

    <input type="file" (change)="onChange($event)"/>


    file-upload.ts

    public onChange(event: Event): void {
    if (event.target.files && event.target.files.length) {
    const [file] = event.target.files;
    console.log(file);
    }
    }


    Typing the event as Event gives me the following Typescript linting error:

    Property 'files' does not exist on type 'EventTarget'


    What should I be typing this if not Event?

    Continue reading...

Compartilhe esta Página