Skip to content

Conversation

cbejensen
Copy link

Add the proper overloads to reflect the fact that this pipe will return a string if given a string, and a string[] if given a string[]. This provides accurate template type checking. For example, if a hypothetical giveMeAString directive expects a string, using this pipe to provide that string would have previously resulted in an error since the pipe's type signature always returned string | string[].

<!-- error TS2322: Type 'string | string[]' is not assignable to type 'string' -->
<my-component giveMeAString="myString | filesize"></my-component>

Add the proper overloads to reflect the fact that this pipe will return a `string` if given a `string`, and a `string[]` if given a `string[]`. This provides accurate template-type checking. For example, if a hypothetical `giveMeAString` directive expects a string, using this pipe to provide that string would have previously resulted in an error since the pipe's type signature always returned `string | string[]`.

```html
<!-- error TS2322: Type 'string | string[]' is not assignable to type 'string' -->
<my-component giveMeAString="myString | filesize"></my-component>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant