Vucript is a typescript dialect that compiles to components of Vue.
With Vucript, you can write your Vue components more simply than normal TypeScript.
- vue: ^3.0.0 (vucript doesn't work on vue 2)
To use Vucript in your Vue CLI project, you need to run
$ vue add vucript
If you want to install to non-Vue CLI project, you need to run
$ npm install vucript --save-dev
You can check our documentation of Vucript here.
Let's write a simple counter app in Vucript.
import { reactive, computed } from "Vucript";
let counter: reactive<number> = 0;
let add = () => {
counter++;
};
const twiceTheCounter: computed<number> = () => counter * 2;
Vucript compiler transforms the above to Vue Composition API Code
import { defineComponent, ref, computed } from "vue";
export default defineComponent({
setup() {
const counter = ref<number>(0);
const add = () => {
counter.value++;
};
const twiceTheCounter = computed(() => counter.value * 2);
return { counter, add, twiceTheCounter };
},
});
Vucript code is more simple than normal Vue Composition API code!
Install vue-cli-plugin-vucript first. Then, please add lang="vucript"
to your Vue Single Component Files.
<script lang="vucript">
import { reactive, computed } from 'Vucript';
let counter:reactive<number> = 0;
let add = () => {
counter++;
};
const twiceTheCounter:computed<number> = (()=>counter*2);
</script>
Please install Vucript globally to use Vucript Command Line Tool.
$ npm install -g vucript
$ vucript component.ts
Import Vucript and run Vucript.compile
function!
import Vucript from "vucript";
let compiled = Vucript.compile(`let counter:reactive<number> = 0;`); //compile function returns compiled string.
Vucript.compileFile(filename, "./"); //compileFile function compiles and save a file.
Please create issue on GitHub or mention @tomu_1576 on Twitter.
Vucript is still in development and incomplete! We need your contribution to make Vucript a better project. Please feel free to mention @tomu_1576 on Twitter if you need any help about contribution!