2

I am trying to learn typescript but i am not clear on few concepts on typescript such as:

1) I am but not the part Object = Object.assign

export const htmlElementsMap: Object = Object.assign(
  {},
  homePageElementsMap,
  loginPageElementsMap,
  productDetailPageElementsMap,
  productListPageElementsMap,
  shoppingBagPageElementsMap,
  thankYouPageElementsMap
);

2) Same with this part export const UrlNavigationMap: Object = { What is an object?

3) For this function i am not sure what does this PromiseLike<void> means:

performAs(actor: PerformsTasks): PromiseLike<void> {
    return actor.attemptsTo(
      Click.on(homePageElementsMap.lnk_men),
      SearchItemBySku.called()
    );
  }

4) export class FillShippingAddress implements Task {} - What does implements means?

and last:

5) What is a static and why it is assigned to the class name?

export class AddItemsToShoppingBag implements Task{
  static called(gender: string): AddItemsToShoppingBag {
    return new AddItemsToShoppingBag(gender);
  }
Ben T
  • 4,656
  • 3
  • 22
  • 22
J Don
  • 65
  • 1
  • 2
  • 6
  • 3
    You have several questions here so you should probably split them up, but a lot of these questions have existing answers. For starters: https://stackoverflow.com/questions/43712705/why-does-typescript-use-like-types – Explosion Pills Jan 24 '18 at 03:23

1 Answers1

6
  1. I am but not the part const htmlElementsMap: Object

:Object is a type annotation. Some notes on type annotations

  1. What is an Object

It is the type of standard JavaScript objects : https://developer.mozilla.org/en-US/docs/Glossary/Object

  1. what does this PromiseLike<void> means:

PromiseLike is something that follows the a+ promise spec : https://promisesaplus.com/

The browser native Promise is one implementation : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise

<void> is a generic type annotation.

  1. What does implements means

It means it follows the types present in the interface.

  1. What is a static and why it is assigned to the class name

What is static: It is a type of member present on classes.

Why it is assigned to the class name: It is not. : AddItemsToShoppingBag is a return type annotation, not an assignment.

basarat
  • 261,912
  • 58
  • 460
  • 511