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

Commit 902754b

Browse files
committed
fix: Vue.jsとTypeScript相性悪い問題に遭遇したため戻り値を明示的に指定して解消した
vuejs/vue#8721
1 parent 14dfc32 commit 902754b

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Diff for: src/components/TodoList.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,20 @@
4040
</template>
4141
<script lang="ts">
4242
import Vue from "vue";
43-
import { Tasks } from "@/interfaces/todolist";
43+
import { Tasks, Task } from "@/interfaces/todolist";
44+
4445
export default Vue.extend({
4546
name: "TodoList",
4647
props: {
4748
type: String,
4849
},
49-
data: function () {
50+
data(): Tasks {
5051
return {
51-
tasks: [{ completed: false, task: "" }] as Tasks,
52+
tasks: [{ completed: false, task: "" }],
5253
};
5354
},
5455
computed: {
55-
filterdTasks() {
56+
filterdTasks(): Task[] {
5657
switch (this.type) {
5758
case "active":
5859
return this.tasks.filter((task) => task.completed === false);

Diff for: src/interfaces/todolist.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export type Tasks = Task[];
1+
export type Tasks = { tasks: Task[] };
22

3-
type Task = {
3+
export type Task = {
44
completed: boolean;
55
task: string;
66
};

0 commit comments

Comments
 (0)