J Don
J Don

Reputation: 65

<promise void> in typescript

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);
  }

Upvotes: 2

Views: 11520

Answers (1)

basarat
basarat

Reputation: 276289

  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.

Upvotes: 6

Related Questions