浏览代码

5.7: function types.

Frederic G. MARAND 6 年之前
父节点
当前提交
6880de3ed8
共有 1 个文件被更改,包括 8 次插入0 次删除
  1. 8 0
      app/app.ts

+ 8 - 0
app/app.ts

@@ -86,3 +86,11 @@ const fictionBookTitles = GetBookTitlesByCategory(Category.Fiction);
 fictionBookTitles.forEach((val, idx, arr) => console.log(`${++idx} ${val}.`));
 
 console.log(GetBookById(2));
+
+function PublicationMessage(year: number): string {
+  return year.toLocaleString();
+}
+
+type publisherFunc = (y: number) => string;
+let publishFunc: publisherFunc = PublicationMessage;
+