Skip to content

Commit 4a91e08

Browse files
committed
Add typescript support
1 parent 3543e6a commit 4a91e08

8 files changed

Lines changed: 89 additions & 27 deletions

File tree

.tslint.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"defaultSeverity": "error",
3+
"extends": [
4+
"tslint:recommended"
5+
],
6+
"jsRules": {},
7+
"rules": {
8+
"quotemark": [
9+
true,
10+
"single"
11+
],
12+
"indent": [
13+
true
14+
],
15+
"interface-name": [
16+
false
17+
],
18+
"arrow-parens": false,
19+
// Pending fix for shorthand property names.
20+
"object-literal-sort-keys": false
21+
},
22+
"rulesDirectory": []
23+
}

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# vue-paper-dashboard-typescript
22

33
> A Vue.js project with TypeScript support
4+
>
5+
> This project was scaffolded using `vue init cristijora/vue-paper-dashboard-cli` command and added TypeScript support on top of it. By using `--allowJs` compiler option we didn't need to modify the original `.js` files.
46
57
## Build Setup
68

build/webpack.base.conf.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ module.exports = {
1919
: config.dev.assetsPublicPath
2020
},
2121
resolve: {
22-
extensions: ['.js', '.vue', '.json'],
22+
extensions: ['.js', '.ts', '.vue', '.json'],
2323
alias: {
2424
'vue$': 'vue/dist/vue.esm.js',
2525
'@': resolve('src'),
@@ -29,12 +29,11 @@ module.exports = {
2929
module: {
3030
rules: [
3131
{
32-
test: /\.(js|vue)$/,
33-
loader: 'eslint-loader',
32+
test: /\.(ts|vue)$/,
33+
loader: 'tslint-loader',
3434
enforce: 'pre',
3535
include: [resolve('src'), resolve('test')],
3636
options: {
37-
formatter: require('eslint-friendly-formatter')
3837
}
3938
},
4039
{
@@ -43,9 +42,12 @@ module.exports = {
4342
options: vueLoaderConfig
4443
},
4544
{
46-
test: /\.js$/,
47-
loader: 'babel-loader',
48-
include: [resolve('src'), resolve('test')]
45+
test: /\.ts$/,
46+
loader: 'ts-loader',
47+
include: [resolve('src'), resolve('test')],
48+
options: {
49+
appendTsSuffixTo: [/\.vue$/]
50+
}
4951
},
5052
{
5153
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,

build/webpack.prod.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ var webpackConfig = merge(baseWebpackConfig, {
6767
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
6868
chunksSortMode: 'dependency'
6969
}),
70-
// keep module.id stable when vender modules does not change
70+
// keep module.id stable when vendor modules do not change
7171
new webpack.HashedModuleIdsPlugin(),
7272
// split vendor js into its own file
7373
new webpack.optimize.CommonsChunkPlugin({

build/webpack.test.conf.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// This is the webpack config used for unit tests.
22

3+
var path = require('path')
34
var utils = require('./utils')
45
var webpack = require('webpack')
56
var merge = require('webpack-merge')
@@ -8,12 +9,26 @@ var baseConfig = require('./webpack.base.conf')
89
var webpackConfig = merge(baseConfig, {
910
// use inline sourcemap for karma-sourcemap-loader
1011
module: {
11-
rules: utils.styleLoaders()
12+
rules: [
13+
{
14+
test: /\.ts$/,
15+
enforce: "pre",
16+
loader: 'istanbul-instrumenter-loader',
17+
include: path.resolve('src/'),
18+
options: {
19+
compilerOptions: {
20+
sourceMap: false,
21+
inlineSourceMap: true
22+
}
23+
}
24+
},
25+
...utils.styleLoaders()
26+
]
1227
},
1328
devtool: '#inline-source-map',
1429
resolveLoader: {
1530
alias: {
16-
// necessary to to make lang="scss" work in test when using vue-loader's ?inject option
31+
// necessary to make lang="scss" work in test when using vue-loader's ?inject option
1732
// see discussion at https://github.com/vuejs/vue-loader/issues/724
1833
'scss-loader': 'sass-loader'
1934
}

package.json

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,23 @@
1111
"unit": "cross-env BABEL_ENV=test karma start test/unit/karma.conf.js --single-run",
1212
"e2e": "node test/e2e/runner.js",
1313
"test": "npm run unit && npm run e2e",
14-
"lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
14+
"lint": "tslint --ext .ts,.vue src test/unit/specs test/e2e/specs"
1515
},
1616
"dependencies": {
1717
"bootstrap": "^3.3.7",
1818
"chartist": "^0.10.1",
1919
"es6-promise": "^4.1.1",
2020
"vue": "^2.4.2",
21+
"vue-class-component": "^5.0.2",
2122
"vue-clickaway": "^2.1.0",
23+
"vue-property-decorator": "^5.3.0",
2224
"vue-router": "^2.7.0"
2325
},
2426
"devDependencies": {
27+
"@types/chartist": "^0.9.35",
28+
"@types/mocha": "^2.2.43",
29+
"@types/sinon-chai": "^2.7.29",
2530
"autoprefixer": "^7.1.2",
26-
"babel-core": "^6.22.1",
27-
"babel-eslint": "^7.1.1",
28-
"babel-loader": "^7.1.1",
29-
"babel-plugin-istanbul": "^4.1.1",
30-
"babel-plugin-transform-runtime": "^6.22.0",
31-
"babel-preset-env": "^1.3.2",
32-
"babel-preset-stage-2": "^6.22.0",
33-
"babel-register": "^6.22.0",
3431
"chai": "^3.5.0",
3532
"chalk": "^2.0.1",
3633
"chromedriver": "^2.27.2",
@@ -40,13 +37,6 @@
4037
"cross-spawn": "^5.0.1",
4138
"css-loader": "^0.28.0",
4239
"cssnano": "^3.10.0",
43-
"eslint": "^3.19.0",
44-
"eslint-config-standard": "^6.2.1",
45-
"eslint-friendly-formatter": "^3.0.0",
46-
"eslint-loader": "^1.7.1",
47-
"eslint-plugin-html": "^3.0.0",
48-
"eslint-plugin-promise": "^3.4.0",
49-
"eslint-plugin-standard": "^2.0.1",
5040
"eventsource-polyfill": "^0.9.6",
5141
"express": "^4.14.1",
5242
"extract-text-webpack-plugin": "^2.0.0",
@@ -78,6 +68,10 @@
7868
"shelljs": "^0.7.6",
7969
"sinon": "^2.1.0",
8070
"sinon-chai": "^2.8.0",
71+
"ts-loader": "^2.3.7",
72+
"tslint": "^5.7.0",
73+
"tslint-loader": "^3.5.3",
74+
"typescript": "^2.5.3",
8175
"url-loader": "^0.5.8",
8276
"vue-loader": "^13.0.4",
8377
"vue-style-loader": "^3.0.1",

test/e2e/nightwatch.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
require('babel-register')
21
var config = require('../../config')
32

43
// http://nightwatchjs.org/gettingstarted#settings-file

tsconfig.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"compilerOptions": {
3+
"module": "es2015",
4+
"moduleResolution": "node",
5+
"target": "es5",
6+
"strict": true,
7+
"noImplicitReturns": true,
8+
"rootDir": ".",
9+
"sourceMap": true,
10+
"experimentalDecorators": true,
11+
"allowJs": true,
12+
"allowSyntheticDefaultImports": true,
13+
"lib": [
14+
"dom",
15+
"es2017"
16+
],
17+
"baseUrl": "./",
18+
"paths": {
19+
"@/*": [
20+
"src/*"
21+
]
22+
}
23+
},
24+
"exclude": [
25+
"node_modules"
26+
]
27+
}

0 commit comments

Comments
 (0)