Added types for vue2-datepicker component (#27108)

* Created types for vue2-datepicker

* Added missing new line

* Enabled strictNullChecks
This commit is contained in:
Christian Stornowski 2018-07-10 00:03:52 +02:00 committed by Mohamed Hegazy
parent b68ae4872a
commit 83f67fa71c
5 changed files with 110 additions and 0 deletions

57
types/vue2-datepicker/index.d.ts vendored Normal file
View File

@ -0,0 +1,57 @@
// Type definitions for vue2-datepicker 2.0
// Project: https://github.com/mengxiong10/vue2-datepicker
// Definitions by: ChristianStornowski <https://github.com/ChristianStornowski>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { Component } from "vue/types/options";
declare namespace Datepicker {
interface Shortcuts {
text: string;
start: Date;
end: Date;
}
interface TimePickerOptions {
start: string;
step: string;
end: string;
}
interface Lang {
days: string[];
months: string[];
pickers: string[];
placeholder: {
date: string;
dateRange: string;
};
}
}
declare const Datepicker: Component<any, any, any, {
type?: string;
range?: boolean;
format?: string;
lang?: string | Datepicker.Lang;
clearable?: boolean;
confirm?: boolean;
editable?: boolean;
disabled?: boolean;
placeholder?: string;
width?: number | string;
notBefore?: string | Date;
notAfter?: string | Date;
disabledDays?: number[] | string[] | ((date: Date) => Date[]);
shortcuts?: boolean | Datepicker.Shortcuts[]
timePickerOptions?: Datepicker.TimePickerOptions[] | (() => Datepicker.TimePickerOptions[]);
minuteStep?: number;
firstDayOfWeek?: number;
inputClass?: string;
inputName?: string;
confirmText?: string;
rangeSeparator?: string;
}>;
export default Datepicker;

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"vue": ">=2.0.0"
}
}

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"vue2-datepicker-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -0,0 +1,23 @@
import Vue from 'vue';
import DatePicker from "vue2-datepicker";
new Vue({
el: '#app',
components: {
DatePicker
},
template: `
<date-picker
:placeholder="placeholder"
v-model="dateOfBirth"
format="YYYY-MM-DD"
lang="en">
<template slot="calendar-icon">
<span class="input-datepicker__icon"></span>
</template>
</date-picker>
`,
data() {
return { dateOfBirth: new Date() };
}
});