This meteor package adds TypeScript support in your single-file .vue
components.
This package is an add-on for akryum:vue-component. You must first have that package installed.
meteor add nathantreid:vue-typescript
Set your script's lang
attribute to ts
or typescript
:
<script lang="ts">
let message: string;
export default {
mounted() {
message = 'world';
console.log(`Hello, ${message}!`);
}
}
</script>
Or with vue-class-component
:
<script lang="typescript">
import Vue from 'vue'
import Component from 'vue-class-component'
let message: string;
@Component
class MyButton extends Vue {
mounted() {
message = 'world';
console.log(`Hello, ${message}!`);
}
}
// The export default has to be on a separate line due to the way the code is transpiled.
export default MyButton;
</script>
This plugin only handles compilation of TypeScript within .vue files. To import other TypeScript files, you must install a .ts compiler such as nathantreid:typescript-babel or barbatus:typescript.
The Babel TypeScript compiler performs transpilation only; type-checking is not supported. As a result, this plugin currently doesn't provide type checking.