vue-typed-mixins
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Vue Typed Mixins

Type safe Vue.js mixins.

Example

This has the same capability of canonical Vue mixins, but is type safe in TypeScript.

import Vue from 'vue'
import mixins from 'vue-typed-mixins'
 
const Foo = Vue.extend({
  data() {
    return {
      foo: 'test'
    }
  }
})
 
const Bar = Vue.extend({
  data() {
    return {
      bar: 123
    }
  }
})
 
const App = mixins(Foo, Bar).extend({
  data() {
    return {
      value: true
    }
  },
 
  computed: {
    concat(): string {
      return `${this.foo} ${this.bar} ${this.value}`
    }
  }
})
 
const vm = new App()
assert(vm.foo === 'test')
assert(vm.bar === 123)
assert(vm.value === true)
assert(vm.concat === 'test 123 true')

License

MIT

/vue-typed-mixins/

    Package Sidebar

    Install

    npm i vue-typed-mixins

    Weekly Downloads

    8,753

    Version

    0.2.0

    License

    MIT

    Unpacked Size

    6.5 kB

    Total Files

    9

    Last publish

    Collaborators

    • ktsn