Skip to content

Commit 9cce40c

Browse files
committed
TS 2.4.1, Vue 2.3.4, ES5
1 parent 8d654ed commit 9cce40c

File tree

10 files changed

+87
-101
lines changed

10 files changed

+87
-101
lines changed

index.d.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import { Vue } from 'vue/types/vue';
22
import { ComponentOptions, PropOptions } from 'vue/types/options';
33

4+
declare class VueGeneric<T> extends Vue { }
5+
export type VirtualClass<T> = { new (): T } & typeof VueGeneric
6+
47
export function Component(options?: ComponentOptions<Vue>): ClassDecorator
58
export function Options(options?: ComponentOptions<Vue>): ClassDecorator
69
export function Prop(options?: PropOptions): PropertyDecorator
710
export function Watch(property: string, deep?:boolean): MethodDecorator
811
export function Mixin<T>(component: { new () : T; }): VirtualClass<T>
912
export function Mixins<T>(...components: { new (); }[]): VirtualClass<T>
1013
export function GlobalMixin(options?: ComponentOptions<Vue>): ClassDecorator
11-
12-
13-
// helpers
14-
export type VirtualClass<T> = {
15-
new (): T
16-
}
1714
export function Virtual<T>(): VirtualClass<T>

index.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
* Released under the MIT license.
88
'*/
99
(function (global, factory) {
10-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
11-
typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) :
12-
(factory((global.VueTyped = global.VueTyped || {}),global.Vue));
10+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
11+
typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) :
12+
(factory((global.VueTyped = {}),global.Vue));
1313
}(this, (function (exports,Vue) { 'use strict';
1414

15-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
15+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
16+
return typeof obj;
17+
} : function (obj) {
18+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
19+
};
1620

1721
var vueInternalPropNames = Object.getOwnPropertyNames(new Vue());
1822
var vueInternalHooks = ['data', 'props', 'watch', 'beforeCreate', 'created', 'beforeMount', 'mounted', 'beforeUpdate', 'updated', 'activated', 'deactivated', 'beforeDestroy', 'destroyed', 'render'];
@@ -172,11 +176,9 @@ function Prop(options) {
172176
};
173177
}
174178

175-
var _typeof$1 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
176-
177179
function Watch(property, deep) {
178180
return function (target, key) {
179-
if (_typeof$1(target['watch']) !== 'object') {
181+
if (_typeof(target['watch']) !== 'object') {
180182
target['watch'] = {};
181183
}
182184
if (!target['watch'][property]) {
@@ -200,10 +202,10 @@ function Mixin(component) {
200202
});
201203
}
202204
function Mixins() {
203-
for (var _len = arguments.length, components = Array(_len), _key = 0; _key < _len; _key++) {
204-
components[_key] = arguments[_key];
205+
var components = [];
206+
for (var _i = 0; _i < arguments.length; _i++) {
207+
components[_i] = arguments[_i];
205208
}
206-
207209
return Vue.extend({
208210
mixins: components
209211
});

package.json

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -35,43 +35,41 @@
3535
"test:browser": "npm run build && npm run test:_browser",
3636
"test": "npm run build && npm run test:_es6 && npm run test:_common && npm run test:_browser"
3737
},
38-
"peerDependencies": {
39-
"vue": "^2.0.5"
40-
},
38+
"license": "MIT",
4139
"devDependencies": {
42-
"@types/chai": "^3.4.34",
43-
"@types/mocha": "^2.2.32",
44-
"@types/node": "^6.0.45",
45-
"babel-core": "^6.9.0",
46-
"babel-loader": "^6.2.4",
40+
"@types/chai": "^4.0.1",
41+
"@types/mocha": "^2.2.41",
42+
"@types/node": "^8.0.9",
43+
"babel-core": "^6.25.0",
44+
"babel-loader": "^7.1.1",
45+
"babel-plugin-external-helpers": "^6.22.0",
4746
"babel-plugin-transform-decorators-legacy": "^1.3.4",
48-
"babel-preset-es2015": "^6.9.0",
47+
"babel-preset-es2015": "^6.24.1",
4948
"babelify": "^7.3.0",
50-
"browser-sync": "^2.17.5",
51-
"chai": "^3.5.0",
52-
"del": "^2.2.2",
49+
"browser-sync": "^2.18.12",
50+
"chai": "^4.0.2",
51+
"del": "^3.0.0",
5352
"gitbook": "^3.2.2",
5453
"gitbook-plugin-edit-link": "^2.0.2",
55-
"gitbook-plugin-github": "^2.0.0",
56-
"glob": "^7.1.1",
54+
"gitbook-plugin-github": "^3.0.0",
55+
"glob": "^7.1.2",
5756
"gulp": "^3.9.1",
58-
"karma": "^0.13.22",
59-
"karma-mocha": "^0.2.2",
60-
"karma-mocha-reporter": "^2.0.3",
61-
"karma-phantomjs-launcher": "^1.0.0",
62-
"karma-webpack": "^1.7.0",
63-
"mocha": "^3.1.2",
64-
"node-libs-browser": "^1.0.0",
65-
"phantomjs-prebuilt": "^2.1.7",
66-
"rollup": "^0.36.1",
67-
"rollup-plugin-babel": "^2.6.1",
57+
"karma": "^1.7.0",
58+
"karma-mocha": "^1.3.0",
59+
"karma-mocha-reporter": "^2.2.3",
60+
"karma-phantomjs-launcher": "^1.0.4",
61+
"karma-webpack": "^2.0.4",
62+
"mocha": "^3.4.2",
63+
"node-libs-browser": "^2.0.0",
64+
"phantomjs-prebuilt": "^2.1.14",
65+
"rollup": "^0.45.0",
66+
"rollup-plugin-babel": "^2.7.1",
6867
"rollup-plugin-typescript": "^0.8.1",
69-
"ts-loader": "^0.8.2",
70-
"ts-node": "^1.6.1",
71-
"typescript": "^2.0.3",
72-
"vue": "^2.1.8",
73-
"webpack": "^1.13.1",
74-
"webpack-merge": "^0.13.0"
75-
},
76-
"license": "MIT"
68+
"ts-loader": "^2.2.2",
69+
"ts-node": "^3.2.0",
70+
"typescript": "^2.4.1",
71+
"vue": "^2.3.4",
72+
"webpack": "^3.1.0",
73+
"webpack-merge": "^4.1.0"
74+
}
7775
}

rollup.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ export default {
1919
moduleName: 'VueTyped',
2020
plugins: [
2121
typescript({ typescript: require('typescript') }),
22-
babel({ 'presets': [['es2015', {'modules': false}]] })
22+
babel({ 'presets': [['es2015', {'modules': false}]], 'plugins': ['external-helpers'] })
2323
],
2424
banner: banner,
2525
globals: {
2626
'vue': 'Vue'
27-
}
27+
},
28+
external: ['vue']
2829
}

test/browser/karma.conf.js

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
var merge = require('webpack-merge')
44
var webpackBase = require('../es6/webpack.config.js')
55

6+
67
module.exports = function (config) {
78
config.set({
89

@@ -15,45 +16,32 @@ module.exports = function (config) {
1516

1617
// list of files / patterns to load in the browser
1718
files: [
18-
'./specs/**/*.ts',
19-
'./specs/**/*.js'
19+
'specs/**/*.ts',
2020
],
2121

2222
// list of files to exclude
23-
exclude: [],
23+
exclude: [
24+
],
2425

2526
// preprocess matching files before serving them to the browser
2627
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
2728
preprocessors: {
2829
'specs/**/*.ts': ['webpack'],
29-
'specs/**/*.js': ['webpack']
30-
},
31-
32-
babelPreprocessor: {
33-
options: {
34-
presets: ['es2015'],
35-
sourceMap: 'inline'
36-
}
3730
},
38-
3931
// webpack preprocessor config
40-
webpack: merge(webpackBase, {
32+
webpack: {
4133
resolve: {
34+
extensions: ['.js', '.ts'],
4235
alias: {
43-
'vue$': 'vue/dist/vue.js'
36+
'vue$': 'vue/dist/vue.common.js'
4437
}
4538
},
4639
module: {
4740
loaders: [
48-
{
49-
test: /\.ts$/,
50-
loader: 'babel!ts',
51-
52-
// resolve: https://github.com/chaijs/chai/issues/384
53-
exclude: /node_modules|vue\/src/
54-
}
55-
]}
56-
}),
41+
{ test: /\.ts(x?)$/, loader: 'ts-loader' }
42+
]
43+
}
44+
},
5745

5846
webpackMiddleware: {
5947
quiet: false,

test/browser/specs/props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('props decorator', () => {
1212
@Component({
1313
template: '<div><div id="text">{{foo}}</div></div>'
1414
})
15-
class Foo {
15+
class Foo extends Vue {
1616

1717
@Prop()
1818
foo: string = 'meh'

test/browser/tsconfig.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"isolatedModules": false,
6+
"moduleResolution": "node",
7+
"declaration": false,
8+
"noImplicitAny": false,
9+
"removeComments": true,
10+
"noLib": false,
11+
"preserveConstEnums": true,
12+
"suppressImplicitAnyIndexErrors": true,
13+
"experimentalDecorators": true
14+
}
15+
}

test/common/specs/options.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ describe('options', () => {
1111

1212
@Options({
1313
props: {
14-
'prop-in-options': 'Foo'
14+
'prop-in-options': {
15+
default: 'Foo'
16+
}
1517
}
1618
})
1719
class Container {
@@ -32,7 +34,7 @@ describe('options', () => {
3234

3335
}
3436

35-
37+
3638
get identity() {
3739
return this.data1;
3840
}
@@ -46,7 +48,7 @@ describe('options', () => {
4648

4749
expect(Container['data'](), 'assert data').to.have.property('data1').eq('the data')
4850
expect(Container, 'assert props').to.have.property('props').to.have.property('prop1').to.have.property('default').eq('the prop')
49-
expect(Container, 'assert props in options').to.have.property('props').to.have.property('prop-in-options').eq('Foo')
51+
expect(Container, 'assert props in options').to.have.property('props').to.have.property('prop-in-options').to.have.property('default').eq('Foo')
5052
expect(Container, 'assert methods').to.have.property('methods').to.have.property('method1').to.be.a('Function')
5153
expect(Container, 'assert created').to.have.property('created').to.be.a('Function')
5254
expect(Container, 'assert watch').to.have.property('watch').to.have.property('data1').to.be.a('Function')
@@ -86,7 +88,9 @@ describe('options', () => {
8688

8789
@Options({
8890
props: {
89-
'prop-in-options': 'Foo'
91+
'prop-in-options': {
92+
default: 'Foo'
93+
}
9094
}
9195
})
9296
class Container extends Parent {
@@ -113,7 +117,7 @@ describe('options', () => {
113117
expect(Container['data'](), 'assert parent data').to.have.property('dataParent').eq('the parent data')
114118
expect(Container['data'](), 'assert super parent data').to.have.property('_identity').eq('')
115119
expect(Container, 'assert props').to.have.property('props').to.have.property('prop1').to.have.property('default').eq('the prop')
116-
expect(Container, 'assert props in options').to.have.property('props').to.have.property('prop-in-options').eq('Foo')
120+
expect(Container, 'assert props in options').to.have.property('props').to.have.property('prop-in-options').to.have.property('default').eq('Foo')
117121
expect(Container, 'assert parent props').to.have.property('props').to.have.property('propParent').to.have.property('default').eq('the parent prop')
118122
expect(Container, 'assert created').to.have.property('created').to.be.a('Function')
119123
expect(Container, 'assert methods').to.have.property('methods').to.have.property('method1').to.be.a('Function')

test/es6/webpack.config.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,11 @@ var glob = require("glob");
33
module.exports = {
44
entry: glob.sync('./test/es6/specs/**/*.*'),
55
output: {
6-
path: './test/es6',
76
filename: 'test.build.js'
87
},
98
module: {
109
loaders: [
11-
{
12-
test: /\.js$/,
13-
exclude: /node_modules|vue\/src/,
14-
loader: 'babel',
15-
}
10+
{ test: /\.js$/, loader: 'babel-loader', query: { presets: ['es2015'], plugins: ['transform-decorators-legacy'], compact: false } }
1611
]
17-
},
18-
babel: {
19-
presets: ['es2015'],
20-
plugins: ['transform-decorators-legacy'],
21-
// fix >100KB issue. see: http://stackoverflow.com/a/29857361/1586914
22-
compact: false
2312
}
2413
}

tsconfig.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"compilerOptions": {
3-
"target": "es6",
3+
"target": "es5",
44
"module": "commonjs",
55
"isolatedModules": false,
66
"moduleResolution": "node",
@@ -10,14 +10,6 @@
1010
"noLib": false,
1111
"preserveConstEnums": true,
1212
"suppressImplicitAnyIndexErrors": true,
13-
"experimentalDecorators": true,
14-
"typeRoots": [
15-
"node_modules/@types"
16-
],
17-
"types": [
18-
"node",
19-
"mocha",
20-
"chai"
21-
]
13+
"experimentalDecorators": true
2214
}
2315
}

0 commit comments

Comments
 (0)