Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions pages/#3.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*====================================================

【TypeScript入門 #3】型推論・型アノテーション・型アサーション、違い分かる?

====================================================*/

/*====================================================

型推論

====================================================*/

// let foo = 123;

// function double(x: number) {
// if (x > 0) {
// return;
// }
// return x * 2;
// }

/*====================================================

型アノテーション

====================================================*/

// function double(x: number): number | undefined {
// if (x > 0) {
// return;
// }
// return x * 2;
// }

/*====================================================

型アサーション

====================================================*/

// let foo = {} as { bar: number };
// let foo = <{ bar: number }>{};

// foo.bar = 1;