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

Typecheck error on v-model Date #65

Open
UpcafeAdmin opened this issue Oct 19, 2021 · 2 comments
Open

Typecheck error on v-model Date #65

UpcafeAdmin opened this issue Oct 19, 2021 · 2 comments
Labels
question Further information is requested

Comments

@UpcafeAdmin
Copy link

Using

  • "vite": "^2.4.3",
  • "vue-tsc": "^0.0.24"
  • "vue3-datepicker": "^0.2.5",
  • "vue": "^3.0.5",

Running

yarn tsc --noEmit

Expected result

No compilation errors.

Actual result

src/views/Contact.vue:17:11 - error TS2741: Property '[Symbol.toPrimitive]' is missing in type '{ toString: () => string; toDateString: () => string; toTimeString: () => string; toLocaleString: { (): string; (locales?: string | string[] | undefined, options?: DateTimeFormatOptions | undefined): string; }; ... 38 more ...; toJSON: (key?: any) => string; }' but required in type 'Date'.

17           v-model="picked"
             ~~~~~~~

  node_modules/vue-tsc/typescript/lib/lib.es2015.symbol.wellknown.d.ts:114:5
    114     [Symbol.toPrimitive](hint: "default"): string;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    '[Symbol.toPrimitive]' is declared here.
  node_modules/vue3-datepicker/dist/types/Datepicker.vue.d.ts:228:5
    228     modelValue?: Date | undefined;
            ~~~~~~~~~~
    The expected type comes from property 'modelValue' which is declared here on type 'Partial<{ placeholder: string; startingView: "day" | "month" | "year"; monthHeadingFormat: string; monthListFormat: string; weekdayFormat: string; inputFormat: string; weekStartsOn: number; disabled: boolean; clearable: boolean; typeable: boolean; minimumView: "day" | ... 1 more ... | "year"; }> & Omit<...> & Omit<....'
@zagoskin
Copy link

zagoskin commented Jan 6, 2023

Currently experiencing the same issue. Our team has resolved it using it like

v-model="(picked as Date)"

But using the as keyword is giving warnings to some other people working in the project.

The weird thing is that some devs do not have the error when using plain v-model=picked as in the OP's example.

The project compiles and works for all of them nevertheless.

@icehaunter
Copy link
Owner

I'm not sure what could be the problem here. I can't reproduce it on a clean latest vite starter with just this project installed. A reproducible example would be appreciated and then I can help debug it. Maybe TS version is the issue?

@icehaunter icehaunter added the question Further information is requested label Jun 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants