For AI agents: the complete documentation index is available at https://types-mediawiki-response.pages.dev/llms.txt, the full documentation bundle is available at https://types-mediawiki-response.pages.dev/llms-full.txt, and this page is available as Markdown at https://types-mediawiki-response.pages.dev/index.md.
  • English
  • types-mediawiki-response

    TypeScript types for MediaWiki Action API responses

    Pure types, zero runtime

    Type declarations only — no impact on your bundle size.

    Cross-version coverage

    One field union across MediaWiki 1.39–1.47.

    Full JSDoc coverage

    Every field is annotated with its parameter and semantics; hover in your IDE and it is there.

    Bundled extensions, opt-in

    Response types for common extensions — one import activates a pack.

    Field types and docs, one hover away

    Types are written field by field from real responses, with JSDoc marking each field's meaning and its source parameter. Hover a response field in your IDE to see it — no doc-digging needed.

    import type { ApiQueryResponse } from "types-mediawiki-response";
    
    const res = (await api.get({
      action: "query",
      meta: "siteinfo",
      siprop: "general",
      formatversion: "2",
    })) as ApiQueryResponse;
    
    const general = res.query.general;
    if (!general) throw new Error("missing query.general");
    
    console.log(`${general.sitename}: ${general.generator(property) ApiSiteGeneral.generator: stringGenerator, e.g. MediaWiki 1.43.0.}`);
    (property) ApiSiteGeneral.generator: stringGenerator, e.g. MediaWiki 1.43.0.

    Errors caught at compile time

    Type and spelling mistakes are caught by TS at compile time. You find out earlier, and the editor suggests the correct spelling for you.

    import type { ApiQueryResponse } from "types-mediawiki-response";
    
    const res = (await api.get({
      action: "query",
      list: "search",
      srsearch: "insource:formatversion",
      formatversion: "2",
    })) as ApiQueryResponse;
    
    const [hit] = res.query.search ?? [];
    
    console.log(`${hit.title}: ${hit.snipetProperty 'snipet' does not exist on type 'ApiSearchHit'. Did you mean snippet?ts(2551)}`);
    $ tsc --noEmitapi.ts:12:34 - error TS2551: Property 'snipet' does not exist on type 'ApiSearchHit'. Did you mean 'snippet'?12 console.log(`${hit.title}: ${hit.snipet}`); ~~~~~~Found 1 error in api.ts:12