Skip to content

Commit

Permalink
feat(): migrate to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
gmq committed Jul 21, 2017
1 parent a2329c8 commit 63fb1d6
Show file tree
Hide file tree
Showing 15 changed files with 350 additions and 58 deletions.
9 changes: 9 additions & 0 deletions app/javascript/custom.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare module '*.vue' {
import Vue from 'vue';
export default Vue;
}

declare module '*.svg' {
const content: any;
export default content;
}
12 changes: 8 additions & 4 deletions app/javascript/packs/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
</div>
</template>

<script>
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
import appHeader from '../trellaw/app-header.vue';
import board from '../trellaw/board.vue';
export default {
components: {
@Component({
components: {
appHeader,
board,
},
}
})
export default class App extends Vue {}
</script>

<style lang="scss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import Vue from 'vue';
import App from './app.vue';

document.addEventListener('DOMContentLoaded', () => {
const app = new Vue(App).$mount('#app');
const app: Vue = new Vue(<any> App).$mount('#app');
});
30 changes: 14 additions & 16 deletions app/javascript/trellaw/app-header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,23 @@
</header>
</template>

<script>
import logo from '../trellaw/images/white-monkey.svg'
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
import logo from '../trellaw/images/white-monkey.svg';
export default {
data() {
return {
logo,
}
}
export default class AppHeader extends Vue {
public logo: string = logo;
}
</script>

<style lang="scss" scoped>
@import 'stylesheets/variables';
.header {
background-color: $header-bg;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
@import 'stylesheets/variables';
.header {
background-color: $header-bg;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}
</style>
14 changes: 9 additions & 5 deletions app/javascript/trellaw/board.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@
</div>
</template>

<script>
import list from './list';
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
export default {
import list from './list.vue';
@Component({
components: {
list,
}
}
},
})
export default class Board extends Vue { }
</script>


Expand Down
16 changes: 8 additions & 8 deletions app/javascript/trellaw/card-target.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
</div>
</template>

<script>
import add from '../trellaw/images/add.svg'
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
export default {
data() {
return {
add,
}
}
import add from '../trellaw/images/add.svg';
@Component
export default class CardTarget extends Vue {
public add: string = add;
}
</script>

Expand Down
20 changes: 13 additions & 7 deletions app/javascript/trellaw/card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@
</div>
</template>

<script>
export default {
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
@Component({
props: ['cardType'],
})
export default class Card extends Vue {
public cardType: string;
}
</script>

<style lang="scss" scoped>
@import './stylesheets/variables';
@import './stylesheets/variables';
.card {
background-color: $card-bg;
border-radius: 4px;
}
.card {
background-color: $card-bg;
border-radius: 4px;
}
</style>
22 changes: 12 additions & 10 deletions app/javascript/trellaw/list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,26 @@
</div>
</template>

<script>
import card from './card';
import cardTarget from './card-target';
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
export default {
import card from './card.vue';
import cardTarget from './card-target.vue';
@Component({
components: {
card,
},
props: {
title: {
default: 'Título',
}
},
},
data() {
return {
dropTarget: cardTarget,
}
}
})
export default class List extends Vue {
public dropTarget: Vue.Component = cardTarget;
public title: string;
}
</script>

Expand Down
8 changes: 8 additions & 0 deletions config/webpack/loaders/typescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
test: /\.ts$/,
exclude: /node_modules|vue\/src/,
loader: 'ts-loader',
options: {
appendTsSuffixTo: [/\.vue$/],
},
};
1 change: 1 addition & 0 deletions config/webpack/loaders/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
options: {
extractCSS: true,
loaders: {
ts: 'ts-loader!tslint-loader',
js: 'babel-loader',
file: 'file-loader',
scss: 'vue-style-loader!css-loader!postcss-loader!sass-loader',
Expand Down
13 changes: 13 additions & 0 deletions hound.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
ruby:
:enabled: true
:config_file: ".rubocop.yml"
eslint:
:enabled: true
:config_file: ".eslintrc.json"
tslint:
:enabled: true
:config_file: tslint.json
scss:
:enabled: true
:config_file: ".scss-lint.yml"
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@
"resolve-url-loader": "^2.0.3",
"sass-loader": "^6.0.6",
"style-loader": "^0.18.2",
"ts-loader": "^2.3.1",
"tslint": "^5.5.0",
"tslint-loader": "^3.5.3",
"typescript": "^2.4.2",
"vue": "^2.4.1",
"vue-class-component": "^5.0.2",
"vue-loader": "^12.2.2",
"vue-template-compiler": "^2.4.1",
"webpack": "^3.0.0",
Expand Down
15 changes: 15 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"lib": ["dom", "es6"],
"module": "es6",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5"
},
"exclude": ["**/*.spec.ts", "node_modules", "public"],
"compileOnSave": false
}
Loading

0 comments on commit 63fb1d6

Please sign in to comment.