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

Cannot set locale 'it': Type '{ locale: string; }' has no properties in common with type 'IDatePickerDirectiveConfig' #604

Open
3 tasks done
Faycop opened this issue Sep 30, 2022 · 7 comments

Comments

@Faycop
Copy link

Faycop commented Sep 30, 2022

Make sure to add all the information needed to understand the bug so that someone can help. If the info is missing we'll add the 'Needs more information' label and close the issue until there is enough information.

  • What's the version of Angular you're using?
    13.3.11

  • Does this occur on specific browser?
    No

  • Provide a minimal code snippet, please make sure it is well formatted.
    I have an input from a reactiveForm like this:

<input type="text" class="form-control form-control-lg form-control-solid" placeholder="01/01/2031" name="data" formControlName="data" [dpDayPicker]="datepickerConfig" theme="dp-material" />

I have to change the locale of dpDayPicker to italian, so datepickerConfig is setted this way:

datepickerConfig = { locale: 'it' };

But on compile I receive the following error:

`
Error: src/app/pages/data-page/page-form.component.html:111:18 - error TS2559: Type '{ locale: string; }' has no properties in common with type 'IDatePickerDirectiveConfig'.

111 [dpDayPicker]="datepickerConfig"
~~~~~~~~~~~

src/app/pages/data-page/page-form.component.ts:19:16
19 templateUrl: './page-form.component.html',
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component FormComponent.

✖ Failed to compile.`

What am I doing wrong?

@vlio20
Copy link
Owner

vlio20 commented Nov 17, 2022

Please provide a stackblitz

@FrancYescO
Copy link

FrancYescO commented Jan 3, 2023

i can confirm the issue.
i think it was broken here https://github.com/vlio20/angular-datepicker/pull/573/files

maybe we need a better documentation on how to set (or load) the locale in "dayjs way"

@vlio20
Copy link
Owner

vlio20 commented Jan 4, 2023

@FrancYescO can you provide a stackblitz?

@FrancYescO
Copy link

FrancYescO commented Jan 4, 2023

not much to do, just add locale: 'it' to the config, seems it was a breaking changes not cited while migrating to dayjs

https://stackblitz.com/edit/angular-s5bfkr?file=src%2Fapp%2Fapp.component.ts
(stackblitz was a clone and edit from one you posted in the past)

@WClouter
Copy link

init dayjs: dayjs.locale(languageCode);

https://day.js.org/docs/en/i18n/changing-locale

@jsstrellix
Copy link

Just started using this component and ran into this issue. Looking forward to a fix hopefully in the not too distant future.

@dreich
Copy link

dreich commented May 15, 2023

At last I've managed to change the locale. Did not find an information anywhere!

In *.ts file I added

import 'dayjs/locale/ru';
import dayjs from "dayjs";

And in the same file in constructor:
dayjs.locale('ru')

Also I had to add to tsconfig.app.json:
"allowSyntheticDefaultImports": true
in "compilerOptions".

In package.json I have
"dayjs": "^1.11.7",

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

No branches or pull requests

6 participants