We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0ca7db0 commit 8632bc6Copy full SHA for 8632bc6
example/tsconfig.json
@@ -7,14 +7,10 @@
7
],
8
"module": "commonjs",
9
"moduleResolution": "node",
10
- "isolatedModules": false,
11
"experimentalDecorators": true,
12
- "noImplicitAny": true,
13
- "noImplicitThis": true,
14
- "strictNullChecks": true,
15
- "removeComments": true,
+ "strict": true,
16
"suppressImplicitAnyIndexErrors": true,
17
- "allowSyntheticDefaultImports": true
+ "removeComments": true
18
},
19
"include": [
20
"./**/*.ts"
package.json
@@ -52,9 +52,9 @@
52
"ts-loader": "^2.2.1",
53
"typescript": "^2.5.2",
54
"uglify-js": "^3.0.22",
55
- "vue": "^2.3.4",
+ "vue": "github:vuejs/vue#dev",
56
"vue-loader": "^13.0.0",
57
- "vue-template-compiler": "^2.3.4",
+ "vue-template-compiler": "^2.4.4",
58
"webpack": "^3.0.0"
59
}
60
src/component.ts
@@ -18,9 +18,9 @@ export const $internalHooks = [
]
export function componentFactory (
21
- Component: VueClass,
22
- options: ComponentOptions<any> = {}
23
-): VueClass {
+ Component: VueClass<Vue>,
+ options: ComponentOptions<any, any, any, any> = {}
+): VueClass<Vue> {
24
options.name = options.name || (Component as any)._componentTag || (Component as any).name
25
// prototype props.
26
const proto = Component.prototype
@@ -62,7 +62,7 @@ export function componentFactory (
62
// find super
63
const superProto = Object.getPrototypeOf(Component.prototype)
64
const Super = superProto instanceof Vue
65
- ? superProto.constructor as VueClass
+ ? superProto.constructor as VueClass<Vue>
66
: Vue
67
return Super.extend(options)
68
src/data.ts
@@ -2,7 +2,7 @@ import Vue from 'vue'
2
import { VueClass } from './declarations'
3
import { noop, warn } from './util'
4
5
-export function collectDataFromConstructor (vm: Vue, Component: VueClass) {
+export function collectDataFromConstructor (vm: Vue, Component: VueClass<Vue>) {
6
// override _init to prevent to init as Vue instance
Component.prototype._init = function (this: Vue) {
// proxy to actual vm
src/declarations.ts
@@ -1,10 +1,10 @@
1
-import Vue from 'vue'
+import Vue, { ComponentOptions } from 'vue'
-export type VueClass = { new (): Vue } & typeof Vue
+export type VueClass<V extends Vue> = { new (...args: any[]): V } & typeof Vue
-export type DecoratedClass = VueClass & {
+export type DecoratedClass = VueClass<Vue> & {
// Property, method and parameter decorators created by `createDecorator` helper
// will enqueue functions that update component options for lazy processing.
// They will be executed just before creating component constructor.
- __decorators__?: ((options: Vue.ComponentOptions<Vue>) => void)[]
+ __decorators__?: ((options: ComponentOptions<any, any, any, any>) => void)[]
src/index.ts
@@ -4,15 +4,13 @@ import { componentFactory, $internalHooks } from './component'
export { createDecorator } from './util'
-function Component <U extends Vue>(options: ComponentOptions<U>): <V extends VueClass>(target: V) => V
-function Component <V extends VueClass>(target: V): V
-function Component <V extends VueClass, U extends Vue>(
- options: ComponentOptions<U> | V
-): any {
+function Component <V extends Vue>(options: ComponentOptions<any, any, any, any> & ThisType<V>): <VC extends VueClass<V>>(target: VC) => VC
+function Component <VC extends VueClass<Vue>>(target: VC): VC
+function Component (options: ComponentOptions<any, any, any, any> | VueClass<Vue>): any {
if (typeof options === 'function') {
return componentFactory(options)
- return function (Component: V) {
+ return function (Component: VueClass<Vue>) {
return componentFactory(Component, options)
src/util.ts
@@ -4,13 +4,13 @@ import { DecoratedClass } from './declarations'
export const noop = () => {}
export function createDecorator (
- factory: (options: ComponentOptions<Vue>, key: string) => void
+ factory: (options: ComponentOptions<any, any, any, any>, key: string) => void
): (target: Vue, key: string) => void
- factory: (options: ComponentOptions<Vue>, key: string, index: number) => void
+ factory: (options: ComponentOptions<any, any, any, any>, key: string, index: number) => void
): (target: Vue, key: string, index: number) => void
): (target: Vue, key: string, index: any) => void {
return (target, key, index) => {
const Ctor = target.constructor as DecoratedClass
test/test.ts
@@ -1,6 +1,6 @@
import Component, { createDecorator } from '../lib'
import { expect } from 'chai'
+import Vue, { ComputedOptions } from 'vue'
describe('vue-class-component', () => {
@@ -197,7 +197,7 @@ describe('vue-class-component', () => {
197
const NoCache = createDecorator((options, key) => {
198
// options should have computed and methods etc.
199
// that specified by class property accessors and methods
200
- const computedOption = options.computed![key] as Vue.ComputedOptions<Vue>
+ const computedOption = options.computed![key] as ComputedOptions<Vue>
201
computedOption.cache = false
202
})
203
tsconfig.json
@@ -8,15 +8,11 @@
"module": "es2015",
"outDir": "lib",
"declaration": true,
"src/**/*.ts"
0 commit comments