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

help(matBadge): Getting error Type 'number' is not assignable to type 'string' with strictTemplates flag #20326

Closed
gauravsoni119 opened this issue Aug 15, 2020 · 1 comment · Fixed by #20331
Assignees
Labels
area: material/badge P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@gauravsoni119
Copy link

What are you trying to do?

I am using the matBadge directive and I need to pass some default value to the matBadge(for example 0, 7, etc). But as I enabled the strictTemplates flag in my tsconfig.json, I am getting an error
Type 'number' is not assignable to type 'string'
since the @Input matBadge is expecting a string.

I can fix it by doing something like:-
@Input() badgeValue = '7';
and then pass it to matBadge directive, but I feel like this is annoying.

Can anyone help me with this?

Environment

  • Angular: 9.0.2
  • Material: 9.2.0
  • Browser(s): Chrome
  • Operating System: Ubuntu
@gauravsoni119 gauravsoni119 added needs triage This issue needs to be triaged by the team troubleshooting This issue is not reporting an issue, but just asking for help labels Aug 15, 2020
@gauravsoni119 gauravsoni119 changed the title help(matBadge): Getting error Type 'number' is not assignable to type 'string' with strictTemplates help(matBadge): Getting error Type 'number' is not assignable to type 'string' with strictTemplates flag Aug 15, 2020
@crisbeto crisbeto added area: material/badge P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team troubleshooting This issue is not reporting an issue, but just asking for help labels Aug 16, 2020
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 16, 2020
Currently the badge's content is limited to `string` which excludes other legitimate use cases like numbers. These changes turn it into an `any` with the option configure it through a generic parameter since we aren't actually doing anything with the value, apart from forwarding it.

Fixes angular#20326.
@crisbeto crisbeto self-assigned this Aug 16, 2020
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 17, 2020
Currently the badge's content is limited to `string` which excludes other legitimate use cases like numbers. These changes turn it into an `any` with the option configure it through a generic parameter since we aren't actually doing anything with the value, apart from forwarding it.

Fixes angular#20326.
crisbeto added a commit to crisbeto/material2 that referenced this issue Aug 17, 2020
Currently the badge's content is limited to `string` which excludes other legitimate use cases like numbers. These changes turn it into an `string | number | undefined | null` since we aren't actually doing anything with the value, apart from forwarding it.

Fixes angular#20326.
wagnermaciel pushed a commit that referenced this issue Aug 20, 2020
Currently the badge's content is limited to `string` which excludes other legitimate use cases like numbers. These changes turn it into an `string | number | undefined | null` since we aren't actually doing anything with the value, apart from forwarding it.

Fixes #20326.
wagnermaciel pushed a commit that referenced this issue Aug 20, 2020
Currently the badge's content is limited to `string` which excludes other legitimate use cases like numbers. These changes turn it into an `string | number | undefined | null` since we aren't actually doing anything with the value, apart from forwarding it.

Fixes #20326.

(cherry picked from commit 75f73ae)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 20, 2020
wagnermaciel pushed a commit to wagnermaciel/components that referenced this issue Jan 14, 2021
Currently the badge's content is limited to `string` which excludes other legitimate use cases like numbers. These changes turn it into an `string | number | undefined | null` since we aren't actually doing anything with the value, apart from forwarding it.

Fixes angular#20326.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: material/badge P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants