3

im curios about an typescript (or maybe angular) error, that i dont fully unterstand. When using the date pipe with timezone parameter and no format:

{{ dateString | date:undefined:'+0430' }}

im getting the following error:

Argument type undefined is not assignable to parameter type string | undefined
Type undefined is not assignable to type string

According to other stackoverflow anwsers, passing undefined to skip an argument should be fine

1 Answer 1

1

I am not able to reproduce the issue on stackblitz!

You could pass mediumDate which is the default formatwhen format parameter is falsy, which generates the same behaviour!

Date Pipe Source Code

Date Pipe Config Source Code

I feel this is just a code editor error which can be ignored, but if you have to remove this error you can do this. Also note, if the default date mediumDate gets changed in the future, the code might not use the default format since we are hardcoding it!

{{ dateString | date : 'mediumDate' : '+0430' }}

Stackblitz Demo

Sign up to request clarification or add additional context in comments.

1 Comment

oh, thanks for your effort so its propably related to some eslint rules or IDE inspections - thanks for pointing that out

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.