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

Commit

Permalink
fix: Vue.jsとTypeScript相性悪い問題に遭遇したため戻り値を明示的に指定して解消した
Browse files Browse the repository at this point in the history
  • Loading branch information
MofuMofu2 committed Apr 12, 2022
1 parent 14dfc32 commit 902754b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions src/components/TodoList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@
</template>
<script lang="ts">
import Vue from "vue";
import { Tasks } from "@/interfaces/todolist";
import { Tasks, Task } from "@/interfaces/todolist";
export default Vue.extend({
name: "TodoList",
props: {
type: String,
},
data: function () {
data(): Tasks {
return {
tasks: [{ completed: false, task: "" }] as Tasks,
tasks: [{ completed: false, task: "" }],
};
},
computed: {
filterdTasks() {
filterdTasks(): Task[] {
switch (this.type) {
case "active":
return this.tasks.filter((task) => task.completed === false);
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/todolist.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type Tasks = Task[];
export type Tasks = { tasks: Task[] };

type Task = {
export type Task = {
completed: boolean;
task: string;
};

0 comments on commit 902754b

Please sign in to comment.