From f893c27fb21f93369c86d01d2e9abbef95c97893 Mon Sep 17 00:00:00 2001 From: Sebastian Moser Date: Thu, 27 Jul 2023 09:26:28 +0100 Subject: [PATCH 1/2] Fixing syntax error & TypeScript warning in todos.md This fixes two small code issues that I came across was I was following the tutorial: First, a syntax error in `todoActions$`. Secondly, a TypeScript warning in the definition of `useTodos`: ``` Type 'IterableIterator' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher. ``` Replacing `[...todosMap.values()]` with `Array.from(todosMap.values())` makes that warning go away without customising TypeScript from its default value. --- docs/tutorial/todos.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/tutorial/todos.md b/docs/tutorial/todos.md index 13ecec6..cad194c 100644 --- a/docs/tutorial/todos.md +++ b/docs/tutorial/todos.md @@ -51,10 +51,10 @@ Which is basically the same as doing this (but a lot shorter, of course :smile:) ```tsx const todoActions$ = merge( - newTodo$.pipe(map(text, id) => ({ - type: "add" as const + newTodo$.pipe(map((text, id) => ({ + type: "add" as const, payload: { id, text }, - })), + }))), editTodo$.pipe(map(payload => ({ type: "edit" as const, payload, @@ -138,7 +138,7 @@ And with this we are ready to start wiring things up. Let's start with the top-level component: ```tsx -const [useTodos] = bind(todosMap$.pipe(map(todosMap => [...todosMap.values()]))) +const [useTodos] = bind(todosMap$.pipe(map(todosMap => Array.from(todosMap.values())))) function TodoList() { const todoList = useTodos() From 04a8a252374a0db66ed05cf2a6bf6c4c57fd4c16 Mon Sep 17 00:00:00 2001 From: Sebastian Moser Date: Fri, 28 Jul 2023 10:34:25 +0100 Subject: [PATCH 2/2] Revert TypeScript warning --- docs/tutorial/todos.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/todos.md b/docs/tutorial/todos.md index cad194c..78cf6cb 100644 --- a/docs/tutorial/todos.md +++ b/docs/tutorial/todos.md @@ -138,7 +138,7 @@ And with this we are ready to start wiring things up. Let's start with the top-level component: ```tsx -const [useTodos] = bind(todosMap$.pipe(map(todosMap => Array.from(todosMap.values())))) +const [useTodos] = bind(todosMap$.pipe(map(todosMap => [...todosMap.values()]))) function TodoList() { const todoList = useTodos()