From 9c48bfe14b5f5219a630502ecafc3afa338734ef Mon Sep 17 00:00:00 2001 From: Ilia Beliaev Date: Thu, 5 Jul 2018 16:47:39 +0300 Subject: [PATCH 1/9] Added support for className option in ImageOverlayOptions. ImageOverlayOptions extends InteractiveLayerOptions as described in Leaflet docs. Added bubblingMouseEvents option to InteractiveLayerOptions. --- types/leaflet/index.d.ts | 4 +++- types/leaflet/leaflet-tests.ts | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/types/leaflet/index.d.ts b/types/leaflet/index.d.ts index 89f9625114..47b2ebc515 100644 --- a/types/leaflet/index.d.ts +++ b/types/leaflet/index.d.ts @@ -390,6 +390,7 @@ export interface LayerOptions { export interface InteractiveLayerOptions extends LayerOptions { interactive?: boolean; + bubblingMouseEvents?: boolean; } export class Layer extends Evented { @@ -542,12 +543,13 @@ export namespace tileLayer { function wms(baseUrl: string, options?: WMSOptions): TileLayer.WMS; } -export interface ImageOverlayOptions extends LayerOptions { +export interface ImageOverlayOptions extends InteractiveLayerOptions { opacity?: number; alt?: string; interactive?: boolean; attribution?: string; crossOrigin?: boolean; + className?: string; } export class ImageOverlay extends Layer { diff --git a/types/leaflet/leaflet-tests.ts b/types/leaflet/leaflet-tests.ts index a22ab91248..1f6671cc8c 100644 --- a/types/leaflet/leaflet-tests.ts +++ b/types/leaflet/leaflet-tests.ts @@ -251,6 +251,29 @@ tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png'); tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', tileLayerOptions); tileLayer = new L.TileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}&{bar}&{abc}', {foo: 'bar', bar: (data: any) => 'foo', abc: () => ''}); +// imageOverlay +let imageOverlayOptions: L.ImageOverlayOptions; +imageOverlayOptions = { + opacity: 100, + alt: 'alt', + interactive: true, + attribution: 'attribution', + crossOrigin: true, + className: 'className', + bubblingMouseEvents: false, + pane: 'pane' +}; + +const imageOverlayBounds = latLngBounds; +let imageOverlay: L.ImageOverlay; +imageOverlay = L.imageOverlay('https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png', imageOverlayBounds); +imageOverlay = L.imageOverlay('https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png', imageOverlayBounds, imageOverlayOptions); +imageOverlay = L.imageOverlay('https://www.google.ru/images/branding/googlelogo/2x/googlelogo_color_120x44dp.png', imageOverlayBounds, { + opacity: 100, + alt: 'alt', + className: 'className', +}); + const eventHandler = () => {}; const domEvent: Event = {} as Event; L.DomEvent From 9afc9e1cdd15d3b8278929858de0b4f44149afd8 Mon Sep 17 00:00:00 2001 From: Ilia Beliaev Date: Thu, 9 Aug 2018 16:41:45 +0300 Subject: [PATCH 2/9] Added vue-select support. --- types/vue-select/index.d.ts | 98 ++++++++++++++++++++++++++++ types/vue-select/package.json | 6 ++ types/vue-select/tsconfig.json | 22 +++++++ types/vue-select/tslint.json | 1 + types/vue-select/vue-select-tests.ts | 11 ++++ types/vue2-datepicker/package.json | 3 +- 6 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 types/vue-select/index.d.ts create mode 100644 types/vue-select/package.json create mode 100644 types/vue-select/tsconfig.json create mode 100644 types/vue-select/tslint.json create mode 100644 types/vue-select/vue-select-tests.ts diff --git a/types/vue-select/index.d.ts b/types/vue-select/index.d.ts new file mode 100644 index 0000000000..f43da99cf1 --- /dev/null +++ b/types/vue-select/index.d.ts @@ -0,0 +1,98 @@ +// Type definitions for vue-select 2.4.0 +// Project: https://github.com/sagalbot/vue-select#readme +// Definitions by: Ilia Beliaev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Typescript version: 2.4.0 + +export default VueSelect; + +export type Option = string | any | null; + +export type OptionConsumer = (option: Option) => void; + +export interface VueSelectProps { + value: Option; + options: Option[]; + disabled: boolean; + maxHeight: string; + searchable: boolean; + multiple: boolean; + placeholder: string; + transition: string; + clearSearchOnSelect: boolean; + closeOnSelect: boolean; + label: boolean; + getOptionLabel: (option: Option) => string; + onChange: OptionConsumer; + taggable: boolean; + tabindex: number | null; + pushTags: boolean; + filterable: boolean; + createOption: (option: Option) => Option; + resetOnOptionsChange: boolean; + noDrop: boolean; + inputId: string | null; + dir: string; +} + +export interface VueSelectData { + search: string; + open: boolean; + mutableValue: Option; + mutableOptions: Option[]; +} + +export interface VueSelectWatch { + value: (val: Option) => void; + mutableValue: (val: Option, old: Option) => void; + options: (val: Option) => void; + mutableOptions: () => void; + multiple: (reset: boolean) => void; + created: () => void; +} + +export interface VueSelectMethods { + select: OptionConsumer; + deselect: OptionConsumer; + clearSelection: () => void; + onAfterSelect: OptionConsumer; + toggleDropdown: (e: Event) => void; + isOptionSelected: (option: Option) => boolean; + onEscape: () => void; + onSearchBlur: () => void; + onSearchFocus: () => void; + maybeDeleteValue: () => void; + optionExists: (option: Option) => boolean; + maybePushTag: OptionConsumer; +} + +export interface VueSelectComputed { + dropdownClasses: () => DropdownClasses; + clearSearchOnBlur: () => boolean; + searching: () => boolean; + dropdownOpen: () => boolean; + searchPlaceholder: () => boolean; + filteredOptions: () => Option[]; + isValueEmpty: () => boolean; + valueAsArray: () => Option[]; + showClearButton: () => boolean; +} + +export interface DropdownClasses { + open: boolean; + single: boolean; + searching: boolean; + searchable: boolean; + unsearchable: boolean; + loading: boolean; + rtl: boolean; + disabled: boolean; +} + +export const VueSelect: { + props: VueSelectProps, + data: () => VueSelectData, + watch: VueSelectWatch, + methods: VueSelectMethods, + computed: VueSelectComputed, +} diff --git a/types/vue-select/package.json b/types/vue-select/package.json new file mode 100644 index 0000000000..faefc1b2f7 --- /dev/null +++ b/types/vue-select/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "vue": ">=2.0.0" + } +} diff --git a/types/vue-select/tsconfig.json b/types/vue-select/tsconfig.json new file mode 100644 index 0000000000..c757293eec --- /dev/null +++ b/types/vue-select/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "vue-select-tests.ts" + ] +} diff --git a/types/vue-select/tslint.json b/types/vue-select/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/vue-select/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/vue-select/vue-select-tests.ts b/types/vue-select/vue-select-tests.ts new file mode 100644 index 0000000000..fd4374b9cd --- /dev/null +++ b/types/vue-select/vue-select-tests.ts @@ -0,0 +1,11 @@ +import Vue from 'vue'; + +new Vue({ + el: '#app', + components: { + 'vue-select': VueSelect + }, + template: { + '' + } +}); diff --git a/types/vue2-datepicker/package.json b/types/vue2-datepicker/package.json index faefc1b2f7..5453d4179e 100644 --- a/types/vue2-datepicker/package.json +++ b/types/vue2-datepicker/package.json @@ -2,5 +2,6 @@ "private": true, "dependencies": { "vue": ">=2.0.0" - } + }, + "typeScriptVersion": "2.4.0" } From a4f1fac64bd1f745c2729ea1fc3f3cfe6406eb7c Mon Sep 17 00:00:00 2001 From: Ilia Beliaev Date: Thu, 9 Aug 2018 16:54:32 +0300 Subject: [PATCH 3/9] Fixed to work properly with lint. --- types/vue-select/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vue-select/index.d.ts b/types/vue-select/index.d.ts index f43da99cf1..5934393505 100644 --- a/types/vue-select/index.d.ts +++ b/types/vue-select/index.d.ts @@ -94,5 +94,5 @@ export const VueSelect: { data: () => VueSelectData, watch: VueSelectWatch, methods: VueSelectMethods, - computed: VueSelectComputed, + computed: VueSelectComputed } From 1ff7ad1434054de6fd4d95e408cb4b6e1f6850b1 Mon Sep 17 00:00:00 2001 From: Ilia Beliaev Date: Thu, 9 Aug 2018 16:54:57 +0300 Subject: [PATCH 4/9] Fixed to work properly with lint. --- types/vue-select/index.d.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/types/vue-select/index.d.ts b/types/vue-select/index.d.ts index 5934393505..9a4e81d4f2 100644 --- a/types/vue-select/index.d.ts +++ b/types/vue-select/index.d.ts @@ -4,8 +4,12 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Typescript version: 2.4.0 +import {VueConstructor} from 'vue'; + export default VueSelect; +export const VueSelect: VueSelectConstructor; + export type Option = string | any | null; export type OptionConsumer = (option: Option) => void; @@ -89,10 +93,10 @@ export interface DropdownClasses { disabled: boolean; } -export const VueSelect: { - props: VueSelectProps, - data: () => VueSelectData, - watch: VueSelectWatch, - methods: VueSelectMethods, - computed: VueSelectComputed +export interface VueSelectConstructor extends VueConstructor{ + props: VueSelectProps; + data: () => VueSelectData; + watch: VueSelectWatch; + methods: VueSelectMethods; + computed: VueSelectComputed; } From a85aec2a7afb85edb9b163e6368b6dc2092ef344 Mon Sep 17 00:00:00 2001 From: Ilia Beliaev Date: Thu, 9 Aug 2018 17:14:22 +0300 Subject: [PATCH 5/9] Changed type from string | any to any. --- types/vue-select/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/vue-select/index.d.ts b/types/vue-select/index.d.ts index 9a4e81d4f2..a718686d26 100644 --- a/types/vue-select/index.d.ts +++ b/types/vue-select/index.d.ts @@ -10,7 +10,7 @@ export default VueSelect; export const VueSelect: VueSelectConstructor; -export type Option = string | any | null; +export type Option = any | null; export type OptionConsumer = (option: Option) => void; From cf0e059ca109cfefecdfca2e68ca9d4efafdc8ea Mon Sep 17 00:00:00 2001 From: Ilia Beliaev Date: Thu, 9 Aug 2018 18:43:52 +0300 Subject: [PATCH 6/9] Fixed label type. Added tests. --- types/vue-select/index.d.ts | 2 +- types/vue-select/vue-select-tests.ts | 62 ++++++++++++++++++++++++++-- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/types/vue-select/index.d.ts b/types/vue-select/index.d.ts index a718686d26..51ae9e4d56 100644 --- a/types/vue-select/index.d.ts +++ b/types/vue-select/index.d.ts @@ -25,7 +25,7 @@ export interface VueSelectProps { transition: string; clearSearchOnSelect: boolean; closeOnSelect: boolean; - label: boolean; + label: string; getOptionLabel: (option: Option) => string; onChange: OptionConsumer; taggable: boolean; diff --git a/types/vue-select/vue-select-tests.ts b/types/vue-select/vue-select-tests.ts index fd4374b9cd..17cf97b2be 100644 --- a/types/vue-select/vue-select-tests.ts +++ b/types/vue-select/vue-select-tests.ts @@ -1,11 +1,67 @@ import Vue from 'vue'; +import VueSelect, {Option} from 'vue-select'; + +const options = [ + { + name: 'SomeName' + }, + { + name: 'SomeName2' + } +] new Vue({ + el: '#app', + data: { + options, + value: null, + + }, components: { 'vue-select': VueSelect }, - template: { - '' - } + methods: { + getOptionLabel(option: Option) { + if (option && option.name) { + return option.name; + } + return ''; + }, + optionConsumer(option: Option) { + }, + optionToOption(option: Option) { + return option; + }, + onSearch(search: string, loading: (b: boolean) => void) { + loading(true); + } + }, + template: ` + + +` }); From e5d5e3587ce0b67f462ff8d450697ce14baee894 Mon Sep 17 00:00:00 2001 From: Ilia Beliaev Date: Thu, 9 Aug 2018 18:48:34 +0300 Subject: [PATCH 7/9] Linting. --- types/vue-select/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/types/vue-select/index.d.ts b/types/vue-select/index.d.ts index 51ae9e4d56..331fa7ec92 100644 --- a/types/vue-select/index.d.ts +++ b/types/vue-select/index.d.ts @@ -93,10 +93,10 @@ export interface DropdownClasses { disabled: boolean; } -export interface VueSelectConstructor extends VueConstructor{ - props: VueSelectProps; - data: () => VueSelectData; - watch: VueSelectWatch; - methods: VueSelectMethods; - computed: VueSelectComputed; +export interface VueSelectConstructor extends VueConstructor { + props: VueSelectProps; + data: () => VueSelectData; + watch: VueSelectWatch; + methods: VueSelectMethods; + computed: VueSelectComputed; } From 4804bb8762075ade689322260fd9f3d9a656ccb1 Mon Sep 17 00:00:00 2001 From: Ilia Beliaev Date: Thu, 9 Aug 2018 18:51:03 +0300 Subject: [PATCH 8/9] Reverted accidental change. --- types/vue2-datepicker/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/vue2-datepicker/package.json b/types/vue2-datepicker/package.json index 5453d4179e..faefc1b2f7 100644 --- a/types/vue2-datepicker/package.json +++ b/types/vue2-datepicker/package.json @@ -2,6 +2,5 @@ "private": true, "dependencies": { "vue": ">=2.0.0" - }, - "typeScriptVersion": "2.4.0" + } } From d7002d4d09fb0374a00ba8d01395c0c1e162b0b0 Mon Sep 17 00:00:00 2001 From: Ilia Beliaev Date: Fri, 10 Aug 2018 10:28:26 +0300 Subject: [PATCH 9/9] Fixes after running lint. --- types/vue-select/index.d.ts | 38 +++++++++++++--------------- types/vue-select/tsconfig.json | 4 ++- types/vue-select/vue-select-tests.ts | 12 ++++----- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/types/vue-select/index.d.ts b/types/vue-select/index.d.ts index 331fa7ec92..ff8767e189 100644 --- a/types/vue-select/index.d.ts +++ b/types/vue-select/index.d.ts @@ -1,22 +1,18 @@ -// Type definitions for vue-select 2.4.0 +// Type definitions for vue-select 2.4 // Project: https://github.com/sagalbot/vue-select#readme // Definitions by: Ilia Beliaev // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Typescript version: 2.4.0 +// TypeScript Version: 2.3 -import {VueConstructor} from 'vue'; +import { VueConstructor } from 'vue'; export default VueSelect; - export const VueSelect: VueSelectConstructor; - -export type Option = any | null; - -export type OptionConsumer = (option: Option) => void; +export type OptionConsumer = (option: any) => void; export interface VueSelectProps { - value: Option; - options: Option[]; + value: any; + options: any[]; disabled: boolean; maxHeight: string; searchable: boolean; @@ -26,13 +22,13 @@ export interface VueSelectProps { clearSearchOnSelect: boolean; closeOnSelect: boolean; label: string; - getOptionLabel: (option: Option) => string; + getOptionLabel: (option: any) => string; onChange: OptionConsumer; taggable: boolean; tabindex: number | null; pushTags: boolean; filterable: boolean; - createOption: (option: Option) => Option; + createOption: (option: any) => any; resetOnOptionsChange: boolean; noDrop: boolean; inputId: string | null; @@ -42,14 +38,14 @@ export interface VueSelectProps { export interface VueSelectData { search: string; open: boolean; - mutableValue: Option; - mutableOptions: Option[]; + mutableValue: any; + mutableOptions: any[]; } export interface VueSelectWatch { - value: (val: Option) => void; - mutableValue: (val: Option, old: Option) => void; - options: (val: Option) => void; + value: (val: any) => void; + mutableValue: (val: any, old: any) => void; + options: (val: any) => void; mutableOptions: () => void; multiple: (reset: boolean) => void; created: () => void; @@ -61,12 +57,12 @@ export interface VueSelectMethods { clearSelection: () => void; onAfterSelect: OptionConsumer; toggleDropdown: (e: Event) => void; - isOptionSelected: (option: Option) => boolean; + isOptionSelected: (option: any) => boolean; onEscape: () => void; onSearchBlur: () => void; onSearchFocus: () => void; maybeDeleteValue: () => void; - optionExists: (option: Option) => boolean; + optionExists: (option: any) => boolean; maybePushTag: OptionConsumer; } @@ -76,9 +72,9 @@ export interface VueSelectComputed { searching: () => boolean; dropdownOpen: () => boolean; searchPlaceholder: () => boolean; - filteredOptions: () => Option[]; + filteredOptions: () => any[]; isValueEmpty: () => boolean; - valueAsArray: () => Option[]; + valueAsArray: () => any[]; showClearButton: () => boolean; } diff --git a/types/vue-select/tsconfig.json b/types/vue-select/tsconfig.json index c757293eec..656897ba29 100644 --- a/types/vue-select/tsconfig.json +++ b/types/vue-select/tsconfig.json @@ -2,11 +2,13 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6" + "es6", + "dom" ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/vue-select/vue-select-tests.ts b/types/vue-select/vue-select-tests.ts index 17cf97b2be..8fea33b2dc 100644 --- a/types/vue-select/vue-select-tests.ts +++ b/types/vue-select/vue-select-tests.ts @@ -1,5 +1,5 @@ import Vue from 'vue'; -import VueSelect, {Option} from 'vue-select'; +import VueSelect from 'vue-select'; const options = [ { @@ -8,29 +8,27 @@ const options = [ { name: 'SomeName2' } -] +]; new Vue({ - el: '#app', data: { options, value: null, - }, components: { 'vue-select': VueSelect }, methods: { - getOptionLabel(option: Option) { + getOptionLabel(option: any) { if (option && option.name) { return option.name; } return ''; }, - optionConsumer(option: Option) { + optionConsumer(option: any) { }, - optionToOption(option: Option) { + optionToOption(option: any) { return option; }, onSearch(search: string, loading: (b: boolean) => void) {