mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-11 09:14:39 +02:00
fix spacing issue
This commit is contained in:
@@ -43,10 +43,10 @@ function bigHorribleAlert(): void {
|
|||||||
|
|
||||||
// The following are equivalent, the same signature will be infered by the
|
// The following are equivalent, the same signature will be infered by the
|
||||||
// compiler, and same JavaScript will be emitted
|
// compiler, and same JavaScript will be emitted
|
||||||
var f1 = function(i: number) : number { return i * i; }
|
var f1 = function(i: number): number { return i * i; }
|
||||||
// Return type inferred
|
// Return type inferred
|
||||||
var f2 = function(i: number) { return i * i; }
|
var f2 = function(i: number) { return i * i; }
|
||||||
var f3 = (i: number) : number => { return i * i; }
|
var f3 = (i: number): number => { return i * i; }
|
||||||
// Return type inferred
|
// Return type inferred
|
||||||
var f4 = (i: number) => { return i * i; }
|
var f4 = (i: number) => { return i * i; }
|
||||||
// Return type inferred, one-liner means no return keyword needed
|
// Return type inferred, one-liner means no return keyword needed
|
||||||
@@ -64,11 +64,11 @@ interface Person {
|
|||||||
|
|
||||||
// Object that implements the "Person" interface
|
// Object that implements the "Person" interface
|
||||||
// Can be treated as a Person since it has the name and move properties
|
// Can be treated as a Person since it has the name and move properties
|
||||||
var p : Person = { name: "Bobby", move : () => {} };
|
var p: Person = { name: "Bobby", move: () => {} };
|
||||||
// Objects that have the optional property:
|
// Objects that have the optional property:
|
||||||
var validPerson : Person = { name: "Bobby", age: 42, move: () => {} };
|
var validPerson: Person = { name: "Bobby", age: 42, move: () => {} };
|
||||||
// Is not a person because age is not a number
|
// Is not a person because age is not a number
|
||||||
var invalidPerson : Person = { name: "Bobby", age: true };
|
var invalidPerson: Person = { name: "Bobby", age: true };
|
||||||
|
|
||||||
// Interfaces can also describe a function type
|
// Interfaces can also describe a function type
|
||||||
interface SearchFunc {
|
interface SearchFunc {
|
||||||
|
Reference in New Issue
Block a user