Skip to content

[TS] Page.content() has incorrect return type #164

@Angoooose

Description

@Angoooose

Page.content() is set to return a promise of a string, however this is not always the case. Sometimes (more often than not it seems) it returns a promise for an array of page sections.

wiki().page('January_12').then(p => p.content()).then(async res => {
    console.log(res);
});
[
  {
    title: 'Events',
    content: '',
    items: [ [Object], [Object], [Object] ]
  },
  {
    title: 'Births',
    content: '',
    items: [ [Object], [Object], [Object] ]
  },
  {
    title: 'Deaths',
    content: '',
    items: [ [Object], [Object], [Object] ]
  },
  {
    title: 'Holidays and observances',
    content: 'Christian feast day:\n' +
      'Aelred of Rievaulx\n' +
      'Benedict Biscop\n' +
      'Bernard of Corleone\n' +
      'Marguerite Bourgeoys\n' +
      'Tatiana\n' +
      'January 12 (Eastern Orthodox liturgics)\n' +
      'Memorial Day (Turkmenistan)\n' +
      'National Youth Day (India)\n' +
      "Prosecutor General's Day (Russia)\n" +
      'Zanzibar Revolution Day (Tanzania)\n' +
      'Aseggwas Amaziɣ, ⴰⵙⴳⴳⴰⵙ ⴰⵎⴰⵣⵉⵖ (Algeria)'
  },
  { title: 'References', content: '' },
  {
    title: 'External links',
    content: 'BBC: On This Day\n' +
      '\n' +
      'The New York Times: On This DayHistorical Events on January 12\n' +
      'Today in Canadian History'
  }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions