[Vuejs]-Enable Typescript in SFC: Laravel 9 + vite + vue-loader

1👍

I figured out the answer to my own question. To help others I’ll take you through the steps. It’s way easier than I thought it was going to be.

Step 1: Install TypeScript

System command: npm install typescript

Or

Laravel Sail Command: ./vendor/bin/sail npm install typescript

Step 2: Add lang attribute to your vue files

Add lang="ts" to your <script> tag

<template>
    This is a test
</template>

<script lang="ts">
export default {
    name: "App",
    mounted() {
        const message: string = "Testing 1 2 3"
        console.log(message)
    }
}
</script>

<style scoped>

</style>

Leave a comment