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

Add overloads to transform method #342

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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