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

@ngrx/component: Better typing for LetDirective and PushPipe #3344

Closed
markostanimirovic opened this issue Mar 9, 2022 · 0 comments · Fixed by #3440
Closed

@ngrx/component: Better typing for LetDirective and PushPipe #3344

markostanimirovic opened this issue Mar 9, 2022 · 0 comments · Fixed by #3440

Comments

@markostanimirovic
Copy link
Member

  • LetDirective: when null or undefined is passed, the type of value is any.
  • PushPipe: there is no signature of transform method that can accept union Observable<...> | null or Observable<...> | undefined.
@markostanimirovic markostanimirovic self-assigned this Mar 9, 2022
@markostanimirovic markostanimirovic added this to To do in NgRx 14 via automation Mar 9, 2022
NgRx 14 automation moved this from To do to Done May 28, 2022
brandonroberts pushed a commit that referenced this issue May 28, 2022
BREAKING CHANGES:

1. The context of `LetDirective` is strongly typed when `null` or
`undefined` is passed as input.

BEFORE:

```html
<p *ngrxLet="null as n">{{ n }}</p>
<p *ngrxLet="undefined as u">{{ u }}</p>
```

- The type of `n` is `any`.
- The type of `u` is `any`.

AFTER:

```html
<p *ngrxLet="null as n">{{ n }}</p>
<p *ngrxLet="undefined as u">{{ u }}</p>
```

- The type of `n` is `null`.
- The type of `u` is `undefined`.

---

2. Arrays, iterables, generator functions, and readable streams are
not treated as observable-like inputs anymore. To keep the same behavior
as in v13, convert the array/iterable/generator function/readable stream
to observable using the `from` function from the `rxjs` package
before passing it to the `LetDirective`/`PushPipe`.

BEFORE:

```ts
@component({
  template: `
    <p *ngrxLet="numbers as n">{{ n }}</p>
    <p>{{ numbers | ngrxPush }}</p>
  `,
})
export class NumbersComponent {
  numbers = [1, 2, 3];
}
```

AFTER:

```ts
@component({
  template: `
    <p *ngrxLet="numbers$ as n">{{ n }}</p>
    <p>{{ numbers$ | ngrxPush }}</p>
  `,
})
export class NumbersComponent {
  numbers$ = from([1, 2, 3]);
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

1 participant