npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

vue-typescript-component

v0.6.3

Published

Decorators to transform TypeScript classes to vue components

Readme

:snowflake: DEPRECATION NOTICE :snowflake:

Official TypeScript support has been added to Vue.js 2.x and the old bindings have been changed considerably since this repository has been created. We recommend to start new projects with Vue CLI.

vue-typescript-component

Use TypeScript 2.0 classes as Vue.js 2.0 components primarily targeting a vueify setup.

Note: This projects targets TypeScript 2.0 and Vue.js 2.0, and uses the built-in type definitions provided by Vue.js 2.0. Please cf. package.json for the tested versions.

For a complete example project using this package, vueify, and supporting Hot Module Replacement, checkout https://github.com/locoslab/vue-typescript-component-example.

Usage

Install: npm install --save-dev vue-typescript-component

Note: TypeScript and Vue.js must be installed as well.

Example Component

import Vue = require('vue')
import * as vts from 'vue-typescript-component'
// see note about import *.vue files below
import * as ChildComponent from './child.vue'

@vts.component({components: {ChildComponent}})
export default class Example extends Vue {
	// this will be 'data'
	aString = 'abc'
	aNumber = 123

	// props with initializer -> sets default value and type
	@vts.prop() aStringPropWithValue = 'abc'
	@vts.prop() aNumberPropWithValue = 123

	// props without initializer -> sets required=true
	@vts.prop() aStringProp: string
	@vts.prop() aNumberProp: number

	// computed props
	get aComputedString(): string { return this.aString }
	set aComputedString(value: string) { this.aString = value }

	get aComputedNumber(): number { return this.aNumber }
	set aComputedNumber(value: number) { this.aNumber = value }

	get aComputedStringGetter(): string { return this.aString }
	get aComputedNumberGetter(): number { return this.aNumber }

	// methods
	aMethod() { /* ... */ }

	// a lifecycle hook (names: http://vuejs.org/api/#Options-Lifecycle-Hooks)
	created() { /* ... */ }

	// watches
	@vts.watch('aString') aStringWatch(val: string, oldVal: string) { /* ... */ }

	// mark as injected, e.g., by a plugin, and do not use in data()
	// names starting with '$' or '_' are always ignored
	@vts.injected() errors: any
}

The class can then be used in a *.vue file:

<template>
...
</template>

<script>
module.exports = require('./example.ts').default.vueComponentOptions
</script>

While it would be possible to support inline TypeScript code in the vue file itself, we prefer separate files to make use of existing IDE/editor and tooling support for TypeScript files.

Note: to use import with *.vue files in TypeScript code, cf. https://github.com/locoslab/vue-typescript-import-dts

Acknowledgements

There are a few other implementations using similar concepts. While this project has been implemented from scratch, https://github.com/itsFrank/vue-typescript and https://github.com/usystems/vuejs-typescript-component have been helpful during development. If this project does not meet your needs, check out the others!

Why this one:

  • Targets Vue.js 2.0.1
  • Works great with vueify which brings Hot Module Replacement
  • Supports Vue.js 2 template pre-compilation during bundling (using vueify)
  • Uses the new type definitions shipped with Vue.js 2.0.1
  • Smart props:
    • if the prop is initialized, the type and default value is set for the prop definition and required=false
    • else the prop is marked as required
    • these settings can be overridden by providing an explicit PropsOptions parameter to the decorator

Contributing

Contributions including bug reports, tests, and documentation are more than welcome. To get started with development:

# once: install dependencies
npm install

# run unit tests in watch mode
npm test -- --watch

# lint & test
npm run prepublish

License

MIT