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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(common): stricter types for SlicePipe #30156

Closed
wants to merge 1 commit into from

Commits on May 13, 2019

  1. feat(common): stricter types for SlicePipe

    Adds overloads to the `transform` methods of `SlicePipe`,
    to have better types than `any` for `value` and `any` as a return.
    With this commit, using `slice` in an `ngFor` still allow to type-check the content of the `ngFor`
    with `fullTemplateTypeCheck` enabled in Ivy:
    
        <div *ngFor="let user of users | slice:0:2">{{ user.typo }}</div>
                                                            |
                                                            `typo` does not exist on type `UserModel`
    
    whereas it is currently not catched (as the return of `slice` is `any`) neither in VE nor in Ivy.
    
    BREAKING CHANGE
    `SlicePipe` now only accepts an array of values, a string, null or undefined.
    This was already the case in practice, and it still throws at runtime if another type is given.
    But it is now a compilation error to try to call it with an unsupported type.
    cexbrayat committed May 13, 2019
    Copy the full SHA
    3fcdd14 View commit details
    Browse the repository at this point in the history