vue3-datepicker icon indicating copy to clipboard operation
vue3-datepicker copied to clipboard

Typecheck error on v-model Date

Open UpcafeAdmin opened this issue 4 years ago • 2 comments

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<....'

UpcafeAdmin avatar Oct 19 '21 14:10 UpcafeAdmin

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.

zagoskin avatar Jan 06 '23 21:01 zagoskin

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 avatar Jun 04 '23 14:06 icehaunter