File tree Expand file tree Collapse file tree 8 files changed +31
-29
lines changed Expand file tree Collapse file tree 8 files changed +31
-29
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,4 @@ node_modules
22example /build.js
33example /build.js.map
44test /test.build.js
5-
6- /index.js
7- /index.d.ts
5+ lib
Original file line number Diff line number Diff line change 11import * as Vue from 'vue'
2- import Component from '../index'
2+ import Component from '../lib/ index'
33
44@Component ( {
55 props : {
Original file line number Diff line number Diff line change 22 "name" : " vue-class-component" ,
33 "version" : " 4.2.0" ,
44 "description" : " ES201X/TypeScript class decorator for Vue components" ,
5- "main" : " index.js" ,
6- "typings" : " index.d.ts" ,
5+ "main" : " lib/ index.js" ,
6+ "typings" : " lib/ index.d.ts" ,
77 "files" : [
8- " index.js" ,
9- " index.d.ts" ,
8+ " lib" ,
109 " tsconfig.json"
1110 ],
1211 "scripts" : {
1312 "build" : " tsc -p ." ,
13+ "clean" : " rm -rf lib" ,
1414 "example" : " npm run build && webpack --config example/webpack.config.js" ,
1515 "dev" : " webpack --config example/webpack.config.js --watch" ,
1616 "test" : " npm run build && webpack --config test/webpack.config.js && mocha test/test.build.js" ,
17- "prepublish" : " npm run build"
17+ "prepublish" : " npm run clean && npm run build"
1818 },
1919 "repository" : {
2020 "type" : " git" ,
Original file line number Diff line number Diff line change 11import * as Vue from 'vue'
2+ import { VueClass } from './declarations'
23
34const internalHooks = [
45 'data' ,
@@ -15,9 +16,7 @@ const internalHooks = [
1516 'render'
1617]
1718
18- export type VueClass = { new ( ) : Vue } & typeof Vue
19-
20- function componentFactory (
19+ export function componentFactory (
2120 Component : VueClass ,
2221 options : Vue . ComponentOptions < any > = { }
2322) : VueClass {
@@ -52,15 +51,3 @@ function componentFactory (
5251 : Vue
5352 return Super . extend ( options )
5453}
55-
56- export default function decorator < U extends Vue > ( options : Vue . ComponentOptions < U > ) : < V extends VueClass > ( target : V ) => V
57- export default function decorator < V extends VueClass > ( target : V ) : V
58- export default function decorator < V extends VueClass > ( options : Vue . ComponentOptions < any > | V ) : any {
59- if ( typeof options === 'function' ) {
60- return componentFactory ( options )
61- }
62- return function ( Component : any ) {
63- return componentFactory ( Component , options )
64- }
65- }
66-
Original file line number Diff line number Diff line change 1+ import * as Vue from 'vue'
2+
3+ export type VueClass = { new ( ) : Vue } & typeof Vue
Original file line number Diff line number Diff line change 1+ import * as Vue from 'vue'
2+ import { VueClass } from './declarations'
3+
4+ import { componentFactory } from './component'
5+
6+ export default function Component < U extends Vue > ( options : Vue . ComponentOptions < U > ) : < V extends VueClass > ( target : V ) => V
7+ export default function Component < V extends VueClass > ( target : V ) : V
8+ export default function Component < V extends VueClass > ( options : Vue . ComponentOptions < any > | V ) : any {
9+ if ( typeof options === 'function' ) {
10+ return componentFactory ( options )
11+ }
12+ return function ( Component : V ) {
13+ return componentFactory ( Component , options )
14+ }
15+ }
Original file line number Diff line number Diff line change 1- import Component from '../index'
1+ import Component from '../lib/ index'
22import { expect } from 'chai'
33import * as Vue from 'vue'
44
Original file line number Diff line number Diff line change 77 ],
88 "module" : " commonjs" ,
99 "moduleResolution" : " node" ,
10+ "outDir" : " lib" ,
1011 "isolatedModules" : false ,
1112 "experimentalDecorators" : true ,
1213 "declaration" : true ,
1617 "removeComments" : true ,
1718 "suppressImplicitAnyIndexErrors" : true
1819 },
19- "exclude" : [
20- " node_modules" ,
21- " test" ,
22- " example"
20+ "include" : [
21+ " src/**/*.ts"
2322 ],
2423 "compileOnSave" : false
2524}
You can’t perform that action at this time.
0 commit comments