I recently started a vue3 project and decided to use TypeScript. Once I had studied some basics I intentionally made a typing mistake but no error appeared:
<script setup lang="ts">
interface Fichier {
nom: string,
taille: number,
contenu: object,
isLoaded: boolean,
}
let itv: Fichier = {
nom: "Fichier 1",
taille: 45,
contenu: [],
isLoaded: false,
etat: []
}
console.log(itv)
I expected the console to show an error but nothing appears.
Judging by the
<script>
tag you're working in a browser.Browsers don't run TypeScript. TypeScript needs to be transpiled to JavaScript to run in a browser.
To get a feel for the language without setting up a local environment you can try the TypeScript playground. Here's a link with the code you posted:
Playground
It clearly shows an error:
Another way is using an editor like VS Code, which shows errors immediately without transpiling to JavaScript.