Unable to add types to input with transform functionality

Discussão em 'Angular' iniciado por Mirco Widmer, Outubro 13, 2024.

  1. Mirco Widmer

    Mirco Widmer Guest

    I have the following snippet:

    filterCriteria = input.required({
    transform: (value: string) => value.toLocaleLowerCase(),
    alias: 'listCriteria'
    });


    I would like to transform the input with a transform method. As soon as I add types to the input.required part, it does not compile anymore with the following error message:


    TS2322: Type '(value: string) => string' is not assignable to type 'undefined'.
    ​

    It is reproducible in this Stackblitz example:

    https://stackblitz.com/edit/signal-inputs-deborahk-rpofup?file=src/snacks/snack-list.component.ts

    My question is, why does this not work? The background of my question is the fact that my template is not happy with the provided type by filterCriteria.

    Continue reading...

Compartilhe esta Página