-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Open
Labels
Description
Version
2.5.13
Reproduction link
https://github.com/zsky/vue-date-type-issue
Steps to reproduce
npm i
npm run build
What is expected?
No typescript error
What is actually happening?
Typescript report error: Property 'getTime' does not exist on type 'string'
I use vue with typescript, I want to set a component prop type as Date, so I do this:
Vue.extend({
props: { start: Date },
created() {
this.start; // Expect type Date, but String
}
});Then I find something could be userful:
In options.d.ts,
export type Prop<T> = { (): T } | { new (...args: any[]): T & object }Make a simple test:
function test<T>(opts: { p1: Prop<T> }): T {
return {} as T;
}
let result = test({ p1: Date }); // Expect type Date, but StringBut I still don't know how to solve it, thanks for any suggestion.
calling