Skip to content

Commit

Permalink
Fixing syntax error & TypeScript warning in todos.md
Browse files Browse the repository at this point in the history
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<Todo>' 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.
  • Loading branch information
sebmos authored Jul 27, 2023
1 parent 74084aa commit f893c27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/tutorial/todos.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit f893c27

Please sign in to comment.