Skip to content

Commit 06776ba

Browse files
committed
fix(todo): JSDocのdestructuringの記法を修正
この書籍の主題ではないので、できるだけコンパクトな方法を採用 - microsoft/TypeScript#24045 - google/closure-compiler#1781 - microsoft/TypeScript#24746 fix #606
1 parent c486cd0 commit 06776ba

File tree

20 files changed

+48
-52
lines changed

20 files changed

+48
-52
lines changed

source/use-case/todoapp/event-model/event-emitter/src/view/html-util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function htmlToElement(html) {
1515

1616
/**
1717
* HTML文字列からDOM Nodeを作成して返す
18-
* @return {HTMLElement}
18+
* @return {Element}
1919
*/
2020
export function element(strings, ...values) {
2121
const htmlString = strings.reduce((result, string, i) => {
@@ -31,8 +31,8 @@ export function element(strings, ...values) {
3131

3232
/**
3333
* コンテナ要素の中身をbodyElementで上書きする
34-
* @param {HTMLElement} bodyElement コンテナ要素の中身となる要素
35-
* @param {HTMLElement} containerElement コンテナ要素
34+
* @param {Element} bodyElement コンテナ要素の中身となる要素
35+
* @param {Element} containerElement コンテナ要素
3636
*/
3737
export function render(bodyElement, containerElement) {
3838
// rootElementの中身を空にする

source/use-case/todoapp/final/create-view/src/model/TodoItemModel.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ let todoIdx = 0;
33

44
export class TodoItemModel {
55
/**
6-
* @param {string} title Todoアイテムのタイトル
7-
* @param {boolean} completed Todoアイテムが完了済みならばtrue、そうでない場合はfalse
6+
* `title`: Todoアイテムのタイトル
7+
* `completed`: Todoアイテムが完了済みならばtrue、そうでない場合はfalse
8+
* @param {{ title: string, completed: boolean }}
89
*/
910
constructor({ title, completed }) {
1011
// idは自動的に連番となりそれぞれのインスタンス毎に異なるものとする

source/use-case/todoapp/final/create-view/src/model/TodoListModel.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ export class TodoListModel extends EventEmitter {
5555

5656
/**
5757
* 指定したidのTodoItemのcompletedを更新する
58-
* @param {number} id
59-
* @param {boolean} completed
58+
* @param {{ id:number, completed: boolean }}
6059
*/
6160
updateTodo({ id, completed }) {
6261
const todoItem = this.items.find(todo => todo.id === id);
@@ -69,7 +68,7 @@ export class TodoListModel extends EventEmitter {
6968

7069
/**
7170
* 指定したidのTodoItemを削除する
72-
* @param {number} id
71+
* @param {{ id: number }}
7372
*/
7473
deleteTodo({ id }) {
7574
// `id`が一致するTodoItemを`this.items`から取り除き、削除する

source/use-case/todoapp/final/create-view/src/view/TodoItemView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class TodoItemView {
66
* @param {TodoItemModel} todoItem
77
* @param {function({id:string, completed: boolean})} onUpdateTodo チェックボックスの更新イベントリスナー
88
* @param {function({id:string)}} onDeleteTodo 削除ボタンのクリックイベントリスナー
9-
* @returns {HTMLElement}
9+
* @returns {Element}
1010
*/
1111
createElement(todoItem, { onUpdateTodo, onDeleteTodo }) {
1212
const todoItemElement = todoItem.completed

source/use-case/todoapp/final/create-view/src/view/TodoListView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class TodoListView {
77
* @param {TodoItemModel[]} todoItems TodoItemModelの配列
88
* @param {function({id:string, completed: boolean})} onUpdateTodo チェックボックスの更新イベントリスナー
99
* @param {function({id:string)}} onDeleteTodo 削除ボタンのクリックイベントリスナー
10-
* @returns {HTMLElement} TodoItemModelの配列に対応したリストのHTML要素
10+
* @returns {Element} TodoItemModelの配列に対応したリストのHTML要素
1111
*/
1212
createElement(todoItems, { onUpdateTodo, onDeleteTodo }) {
1313
const todoListElement = element`<ul />`;

source/use-case/todoapp/final/create-view/src/view/html-util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function htmlToElement(html) {
1515

1616
/**
1717
* HTML文字列からDOM Nodeを作成して返す
18-
* @return {HTMLElement}
18+
* @return {Element}
1919
*/
2020
export function element(strings, ...values) {
2121
const htmlString = strings.reduce((result, string, i) => {
@@ -31,8 +31,8 @@ export function element(strings, ...values) {
3131

3232
/**
3333
* コンテナ要素の中身をbodyElementで上書きする
34-
* @param {HTMLElement} bodyElement コンテナ要素の中身となる要素
35-
* @param {HTMLElement} containerElement コンテナ要素
34+
* @param {Element} bodyElement コンテナ要素の中身となる要素
35+
* @param {Element} containerElement コンテナ要素
3636
*/
3737
export function render(bodyElement, containerElement) {
3838
// rootElementの中身を空にする

source/use-case/todoapp/final/final/src/App.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,15 @@ export class App {
1919

2020
/**
2121
* Todoの状態を更新時に呼ばれるリスナー関数
22-
* @param {number} id
23-
* @param {boolean} completed
22+
* @param {{ id:number, completed: boolean }}
2423
*/
2524
handleUpdate({ id, completed }) {
2625
this.todoListModel.updateTodo({ id, completed });
2726
};
2827

2928
/**
3029
* Todoを削除時に呼ばれるリスナー関数
31-
* @param {number} id
30+
* @param {{ id: number }}
3231
*/
3332
handleDelete({ id }) {
3433
this.todoListModel.deleteTodo({ id });
@@ -56,10 +55,7 @@ export class App {
5655

5756
formElement.addEventListener("submit", (event) => {
5857
event.preventDefault();
59-
this.todoListModel.addTodo(new TodoItemModel({
60-
title: inputElement.value,
61-
completed: false
62-
}));
58+
this.handleAdd(inputElement.value);
6359
inputElement.value = "";
6460
});
6561
}

source/use-case/todoapp/final/final/src/model/TodoItemModel.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ let todoIdx = 0;
33

44
export class TodoItemModel {
55
/**
6-
* @param {string} title Todoアイテムのタイトル
7-
* @param {boolean} completed Todoアイテムが完了済みならばtrue、そうでない場合はfalse
6+
* `title`: Todoアイテムのタイトル
7+
* `completed`: Todoアイテムが完了済みならばtrue、そうでない場合はfalse
8+
* @param {{ title: string, completed: boolean }}
89
*/
910
constructor({ title, completed }) {
1011
// idは自動的に連番となりそれぞれのインスタンス毎に異なるものとする

source/use-case/todoapp/final/final/src/model/TodoListModel.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ export class TodoListModel extends EventEmitter {
5555

5656
/**
5757
* 指定したidのTodoItemのcompletedを更新する
58-
* @param {number} id
59-
* @param {boolean} completed
58+
* @param {{ id:number, completed: boolean }}
6059
*/
6160
updateTodo({ id, completed }) {
6261
const todoItem = this.items.find(todo => todo.id === id);
@@ -69,7 +68,7 @@ export class TodoListModel extends EventEmitter {
6968

7069
/**
7170
* 指定したidのTodoItemを削除する
72-
* @param {number} id
71+
* @param {{ id: number }}
7372
*/
7473
deleteTodo({ id }) {
7574
// `id`が一致するTodoItemを`this.items`から取り除き、削除する

source/use-case/todoapp/final/final/src/view/TodoItemView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class TodoItemView {
66
* @param {TodoItemModel} todoItem
77
* @param {function({id:string, completed: boolean})} onUpdateTodo チェックボックスの更新イベントリスナー
88
* @param {function({id:string)}} onDeleteTodo 削除ボタンのクリックイベントリスナー
9-
* @returns {HTMLElement}
9+
* @returns {Element}
1010
*/
1111
createElement(todoItem, { onUpdateTodo, onDeleteTodo }) {
1212
const todoItemElement = todoItem.completed

source/use-case/todoapp/final/final/src/view/TodoListView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class TodoListView {
77
* @param {TodoItemModel[]} todoItems TodoItemModelの配列
88
* @param {function({id:string, completed: boolean})} onUpdateTodo チェックボックスの更新イベントリスナー
99
* @param {function({id:string)}} onDeleteTodo 削除ボタンのクリックイベントリスナー
10-
* @returns {HTMLElement} TodoItemModelの配列に対応したリストのHTML要素
10+
* @returns {Element} TodoItemModelの配列に対応したリストのHTML要素
1111
*/
1212
createElement(todoItems, { onUpdateTodo, onDeleteTodo }) {
1313
const todoListElement = element`<ul />`;

source/use-case/todoapp/final/final/src/view/html-util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function htmlToElement(html) {
1515

1616
/**
1717
* HTML文字列からDOM Nodeを作成して返す
18-
* @return {HTMLElement}
18+
* @return {Element}
1919
*/
2020
export function element(strings, ...values) {
2121
const htmlString = strings.reduce((result, string, i) => {
@@ -31,8 +31,8 @@ export function element(strings, ...values) {
3131

3232
/**
3333
* コンテナ要素の中身をbodyElementで上書きする
34-
* @param {HTMLElement} bodyElement コンテナ要素の中身となる要素
35-
* @param {HTMLElement} containerElement コンテナ要素
34+
* @param {Element} bodyElement コンテナ要素の中身となる要素
35+
* @param {Element} containerElement コンテナ要素
3636
*/
3737
export function render(bodyElement, containerElement) {
3838
// rootElementの中身を空にする

source/use-case/todoapp/form-event/add-todo-item/src/view/html-util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function htmlToElement(html) {
1515

1616
/**
1717
* HTML文字列からDOM Nodeを作成して返す
18-
* @return {HTMLElement}
18+
* @return {Element}
1919
*/
2020
export function element(strings, ...values) {
2121
const htmlString = strings.reduce((result, string, i) => {
@@ -31,8 +31,8 @@ export function element(strings, ...values) {
3131

3232
/**
3333
* コンテナ要素の中身をbodyElementで上書きする
34-
* @param {HTMLElement} bodyElement コンテナ要素の中身となる要素
35-
* @param {HTMLElement} containerElement コンテナ要素
34+
* @param {Element} bodyElement コンテナ要素の中身となる要素
35+
* @param {Element} containerElement コンテナ要素
3636
*/
3737
export function render(bodyElement, containerElement) {
3838
// rootElementの中身を空にする

source/use-case/todoapp/update-delete/add-checkbox/src/model/TodoItemModel.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ let todoIdx = 0;
33

44
export class TodoItemModel {
55
/**
6-
* @param {string} title Todoアイテムのタイトル
7-
* @param {boolean} completed Todoアイテムが完了済みならばtrue、そうでない場合はfalse
6+
* `title`: Todoアイテムのタイトル
7+
* `completed`: Todoアイテムが完了済みならばtrue、そうでない場合はfalse
8+
* @param {{ title: string, completed: boolean }}
89
*/
910
constructor({ title, completed }) {
1011
// idは自動的に連番となりそれぞれのインスタンス毎に異なるものとする

source/use-case/todoapp/update-delete/add-checkbox/src/view/html-util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function htmlToElement(html) {
1515

1616
/**
1717
* HTML文字列からDOM Nodeを作成して返す
18-
* @return {HTMLElement}
18+
* @return {Element}
1919
*/
2020
export function element(strings, ...values) {
2121
const htmlString = strings.reduce((result, string, i) => {
@@ -31,8 +31,8 @@ export function element(strings, ...values) {
3131

3232
/**
3333
* コンテナ要素の中身をbodyElementで上書きする
34-
* @param {HTMLElement} bodyElement コンテナ要素の中身となる要素
35-
* @param {HTMLElement} containerElement コンテナ要素
34+
* @param {Element} bodyElement コンテナ要素の中身となる要素
35+
* @param {Element} containerElement コンテナ要素
3636
*/
3737
export function render(bodyElement, containerElement) {
3838
// rootElementの中身を空にする

source/use-case/todoapp/update-delete/delete-feature/src/model/TodoListModel.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ export class TodoListModel extends EventEmitter {
5454
}
5555

5656
/**
57-
* 指定したidのTodoItemのcompletedを更新する
58-
* @param {number} id
59-
* @param {boolean} completed
57+
* 指定した`id`のTodoItemの`completed`を更新する
58+
* @param {{ id:number, completed: boolean }}
6059
*/
6160
updateTodo({ id, completed }) {
6261
const todoItem = this.items.find(todo => todo.id === id);
@@ -73,7 +72,7 @@ export class TodoListModel extends EventEmitter {
7372
// ===============================
7473
/**
7574
* 指定したidのTodoItemを削除する
76-
* @param {number} id
75+
* @param {{ id: number }}
7776
*/
7877
deleteTodo({ id }) {
7978
// `id`が一致するTodoItemを`this.items`から取り除き、削除する

source/use-case/todoapp/update-delete/delete-feature/src/view/html-util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function htmlToElement(html) {
1515

1616
/**
1717
* HTML文字列からDOM Nodeを作成して返す
18-
* @return {HTMLElement}
18+
* @return {Element}
1919
*/
2020
export function element(strings, ...values) {
2121
const htmlString = strings.reduce((result, string, i) => {
@@ -31,8 +31,8 @@ export function element(strings, ...values) {
3131

3232
/**
3333
* コンテナ要素の中身をbodyElementで上書きする
34-
* @param {HTMLElement} bodyElement コンテナ要素の中身となる要素
35-
* @param {HTMLElement} containerElement コンテナ要素
34+
* @param {Element} bodyElement コンテナ要素の中身となる要素
35+
* @param {Element} containerElement コンテナ要素
3636
*/
3737
export function render(bodyElement, containerElement) {
3838
// rootElementの中身を空にする

source/use-case/todoapp/update-delete/update-feature/src/model/TodoItemModel.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ let todoIdx = 0;
33

44
export class TodoItemModel {
55
/**
6-
* @param {string} title Todoアイテムのタイトル
7-
* @param {boolean} completed Todoアイテムが完了済みならばtrue、そうでない場合はfalse
6+
* `title`: Todoアイテムのタイトル
7+
* `completed`: Todoアイテムが完了済みならばtrue、そうでない場合はfalse
8+
* @param {{ title: string, completed: boolean }}
89
*/
910
constructor({ title, completed }) {
1011
// idは自動的に連番となりそれぞれのインスタンス毎に異なるものとする

source/use-case/todoapp/update-delete/update-feature/src/model/TodoListModel.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ export class TodoListModel extends EventEmitter {
5858
// ===============================
5959
/**
6060
* 指定したidのTodoItemのcompletedを更新する
61-
* @param {number} id
62-
* @param {boolean} completed
61+
* @param {{ id:number, completed: boolean }}
6362
*/
6463
updateTodo({ id, completed }) {
6564
// `id`が一致するTodoItemを見つけ、あるなら完了状態の値を更新する

source/use-case/todoapp/update-delete/update-feature/src/view/html-util.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function htmlToElement(html) {
1515

1616
/**
1717
* HTML文字列からDOM Nodeを作成して返す
18-
* @return {HTMLElement}
18+
* @return {Element}
1919
*/
2020
export function element(strings, ...values) {
2121
const htmlString = strings.reduce((result, string, i) => {
@@ -31,8 +31,8 @@ export function element(strings, ...values) {
3131

3232
/**
3333
* コンテナ要素の中身をbodyElementで上書きする
34-
* @param {HTMLElement} bodyElement コンテナ要素の中身となる要素
35-
* @param {HTMLElement} containerElement コンテナ要素
34+
* @param {Element} bodyElement コンテナ要素の中身となる要素
35+
* @param {Element} containerElement コンテナ要素
3636
*/
3737
export function render(bodyElement, containerElement) {
3838
// rootElementの中身を空にする

0 commit comments

Comments
 (0)