1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-07 07:16:42 +02:00

[typescript/en] multiple types (#4803)

This commit is contained in:
Albert
2024-05-14 21:34:54 -05:00
committed by GitHub
parent 07b055e8f1
commit 69f7f5d856

View File

@@ -72,6 +72,11 @@ let f4 = (i: number) => { return i * i; }
// keyword needed // keyword needed
let f5 = (i: number) => i * i; let f5 = (i: number) => i * i;
// Functions can accept more than one type
function f6(i: string | number): void {
console.log("The value was " + i);
}
// Interfaces are structural, anything that has the properties is compliant with // Interfaces are structural, anything that has the properties is compliant with
// the interface // the interface
interface Person { interface Person {