-4

Easy question for someone to answer, what happens in this typescript function?

getTweetCount = () => this.data.totalCount;

data.totalCount is of type number from a service.

Les Paul
  • 1,260
  • 5
  • 22
  • 46
  • 2
    You're assigning a no-arg function that returns the total count to the name `getTweetCount`. Subsequently you could therefore do e.g. `count = getTweetCount()`. – jonrsharpe Oct 22 '16 at 16:30
  • This has nothing to do with TypeScript (not "typescript'). It's just plain old ES6. –  Oct 23 '16 at 05:25

1 Answers1

0
getTweetCount = () => this.data.totalCount;

You are creating an "arrow function" that returns this.data.totalCount. There are lots of docs about arrow functions out there.

More

Arrow functions are also covered here : https://basarat.gitbooks.io/typescript/content/docs/arrow-functions.html

basarat
  • 261,912
  • 58
  • 460
  • 511
  • Good to know, thank you. – Les Paul Oct 23 '16 at 01:26
  • Please note that, as it stands, this doesn't actually explain what an arrow function is. I've included clear attribution to avoid it being spam, but adding that into the answer itself would be better. – jonrsharpe Oct 23 '16 at 11:58