Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Commit

Permalink
Add TypeScript support for tasks in TodoList component
Browse files Browse the repository at this point in the history
  • Loading branch information
29deepanshutyagi committed Oct 10, 2024
1 parent 647df7b commit 5f9e51c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions javascript/dwa-starter-vue/src/components/TodoList.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
<script setup lang="ts">
import { ref } from 'vue';
// Define a list of tasks
const tasks = ref([
]);
// Define the Task interface
interface Task {
id: number;
title: string;
completed: boolean;
}
// Explicitly type the tasks array
const tasks = ref<Task[]>([]);
const newTask = ref('');
const editingTaskId = ref<number | null>(null);
Expand All @@ -15,7 +20,7 @@ const addTask = () => {
tasks.value.push({
id: Date.now(),
title: newTask.value,
completed: false
completed: false,
});
newTask.value = ''; // Clear the input after adding
}
Expand Down

0 comments on commit 5f9e51c

Please sign in to comment.