Skip to content

Commit 9db09d6

Browse files
committed
Support Vue 2.5
1 parent fd10015 commit 9db09d6

18 files changed

+13056
-30
lines changed

package-lock.json

Lines changed: 13029 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Common helpers.
33
*/
44

5-
import * as Vue from 'vue';
5+
import Vue from 'vue';
66

77
/**
88
* Vue object declarations from "T".

src/lib/component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as Vue from 'vue'
2-
import { ComponentOptions } from 'vue/types/options';
1+
import Vue, { ComponentOptions } from 'vue'
32
import { BuildOptions } from './utils';
43

54
/**

src/lib/mixins-global.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as Vue from 'vue'
2-
import { ComponentOptions } from 'vue/types/options';
1+
import Vue, { ComponentOptions } from 'vue'
32
import { BuildOptions } from './utils';
43

54
/**
@@ -12,7 +11,7 @@ import { BuildOptions } from './utils';
1211
export function GlobalMixin(options?: ComponentOptions<Vue>): ClassDecorator {
1312

1413
var factory = function (Component: Function, options?: any): void {
15-
Vue.mixin(BuildOptions(Component, options))
14+
Vue.mixin(BuildOptions(Component, options) as any)
1615
}
1716

1817
return function (Component) {

src/lib/mixins.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as Vue from 'vue'
1+
import Vue, { ComponentOptions } from 'vue';
22
import { VirtualClass } from "./common";
33

44
/**
@@ -9,9 +9,9 @@ import { VirtualClass } from "./common";
99
* @param {{ new () : T; }} component
1010
* @returns {VirtualClass<T>}
1111
*/
12-
export function Mixin<T>(component: { new(): T; }): VirtualClass<T> {
12+
export function Mixin<T>(component: ({ new(): T; } | ComponentOptions<Vue> | typeof Vue)): VirtualClass<T> {
1313
return Vue.extend({
14-
mixins: [component]
14+
mixins: [component as ComponentOptions<Vue> | typeof Vue]
1515
}) as any
1616
}
1717

@@ -23,8 +23,8 @@ export function Mixin<T>(component: { new(): T; }): VirtualClass<T> {
2323
* @param {...{ new () : any; }[]} components
2424
* @returns {VirtualClass<T>}
2525
*/
26-
export function Mixins<T>(...components: { new(): any; }[]): VirtualClass<T> {
26+
export function Mixins<T>(...components: ({ new(): any; } | ComponentOptions<Vue> | typeof Vue)[]): VirtualClass<T> {
2727
return Vue.extend({
28-
mixins: components
28+
mixins: components as (ComponentOptions<Vue> | typeof Vue)[]
2929
}) as any
3030
}

src/lib/options.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import * as Vue from 'vue'
2-
import { ComponentOptions } from 'vue/types/options';
1+
import Vue, { ComponentOptions } from 'vue'
32
import { BuildOptions } from './utils';
43

54
/**
@@ -21,7 +20,7 @@ export function Options(options?: ComponentOptions<Vue>): ClassDecorator {
2120
var keys = Object.getOwnPropertyNames(Super.prototype)
2221
for (var i = 0; i < keys.length; i++) {
2322
var key = keys[i]
24-
var descriptor = Object.getOwnPropertyDescriptor(Super.prototype, key);
23+
var descriptor = Object.getOwnPropertyDescriptor(Super.prototype, key) as PropertyDecorator;
2524
if (!Component.prototype.hasOwnProperty(key))
2625
Object.defineProperty(Component.prototype, key, descriptor)
2726
}

src/lib/utils.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
* Internal utilities.
33
*/
44

5-
import * as Vue from 'vue'
6-
import { ComponentOptions } from "vue";
5+
import Vue, { ComponentOptions, VueConstructor } from "vue";
76

87
let vueInternalPropNames = Object.getOwnPropertyNames(new Vue());
98
let vueInternalHooks = [
@@ -28,7 +27,7 @@ export const PROP_KEY = '$_vt_props'
2827

2928

3029
/** @internal */
31-
export function BuildOptions(Component: Function & ComponentOptions<Vue>, options?: any): <Function>(target: any) => Function | void {
30+
export function BuildOptions(Component: Function & ComponentOptions<Vue>, options?: any): <Function>(target: any) => VueConstructor | void {
3231

3332
// evaluate component name
3433
if (!options) {
@@ -61,7 +60,7 @@ export function BuildOptions(Component: Function & ComponentOptions<Vue>, option
6160
for (let i = 0; i < propNames.length; i++) {
6261
let prop = propNames[i];
6362
let propVal = undefined;
64-
let descriptor = Object.getOwnPropertyDescriptor(propAttrs, prop)
63+
let descriptor = Object.getOwnPropertyDescriptor(propAttrs, prop) as PropertyDescriptor
6564
let constructorDefault = constructor[prop];
6665

6766
if (typeof (descriptor.value) === 'object') {
@@ -119,7 +118,7 @@ export function BuildOptions(Component: Function & ComponentOptions<Vue>, option
119118
}
120119

121120

122-
let descriptor = Object.getOwnPropertyDescriptor(proto, key)
121+
let descriptor = Object.getOwnPropertyDescriptor(proto, key) as PropertyDescriptor
123122
if (typeof descriptor.value === 'function') {
124123

125124
// methods
@@ -169,7 +168,7 @@ export function BuildOptions(Component: Function & ComponentOptions<Vue>, option
169168

170169
// set data default values initialized from constructor
171170
dataNames.forEach(function (prop) {
172-
let descriptor = Object.getOwnPropertyDescriptor(constructor, prop)
171+
let descriptor = Object.getOwnPropertyDescriptor(constructor, prop) as PropertyDescriptor
173172
if (!descriptor.get && !descriptor.set && typeof descriptor.value !== 'function') {
174173
data_obj[prop] = constructor[prop]
175174
}

test/browser/specs/computed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component } from '../../../dist/index'
22
import { expect } from 'chai'
3-
import * as Vue from 'vue'
3+
import Vue from 'vue'
44

55
describe('methods and computed', () => {
66
it('should take normal methods and getter setter', (done) => {

test/browser/specs/methods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component } from '../../../dist/index'
22
import { expect } from 'chai'
3-
import * as Vue from 'vue'
3+
import Vue from 'vue'
44

55

66
describe('methods', () => {

test/browser/specs/props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, Prop } from '../../../dist/index'
22
import { expect } from 'chai'
3-
import * as Vue from 'vue'
3+
import Vue from 'vue'
44

55

66
describe('props decorator', () => {

0 commit comments

Comments
 (0)