Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.56 KB

README.md

File metadata and controls

54 lines (40 loc) · 1.56 KB

Integrate TypeScript with vue single-file components for Meteor

This meteor package adds TypeScript support in your single-file .vue components.

Prerequisites

This package is an add-on for akryum:vue-component. You must first have that package installed.

Installation

meteor add nathantreid:vue-typescript

Usage

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>

Importing TypeScript files

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.

TypeScript compilation notes

The Babel TypeScript compiler performs transpilation only; type-checking is not supported. As a result, this plugin currently doesn't provide type checking.