Skip to content

Commit 881a050

Browse files
author
janriemer
committed
update example for type shorthands
When introducing type shorthands (aliases), the types that are defined weren't used in the code example. Add an example of how to use them.
1 parent f22967b commit 881a050

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

02-type-system-introduction/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ Types can also be used with a shorthand syntax. In parameters, for instance, one
9191
type HelloWorld = string
9292
type PrimitiveArray = Array<string | number | boolean>
9393

94+
// we can now use our type alias as a normal type...
95+
function print(): HelloWorld {
96+
return 'Hello World'
97+
}
98+
99+
var mixedArray: PrimitiveArray = [42, 'is', 'definitely', true]
100+
101+
// ...or we can write an inline interface in parameters
94102
function getLabel (obj: { label: string }): string {
95103
return obj.label
96104
}

0 commit comments

Comments
 (0)