mwbot-ts - v1.2.7
    Preparing search index...

    Interface WikilinkStatic

    This interface defines the static members of the Wikilink class. For instance members, see Wikilink (defined separately due to TypeScript limitations).

    Wikilink is a class that serves to parse [[wikilink]] markups into an object structure, which is accessible via Mwbot.Wikilink. Note that wikilinks with a 'File:' title are treated differently by the FileWikilink class, and those with an invalid title by the RawWikilink class.

    const foo = new mwbot.Wikilink('Foo');
    foo.setDisplay('Bar');
    foo.stringify(); // [[Foo|Bar]]
    interface WikilinkStatic {
        new WikilinkStatic(title: string | Title, display?: string): Wikilink;
        is<T extends keyof WikilinkTypeMap>(
            obj: unknown,
            type: T,
        ): obj is WikilinkTypeMap[T];
    }

    Hierarchy

    Index

    Constructors

    Methods

    Constructors

    • Creates a new instance.

      Usage:

      const wikilink = new mwbot.Wikilink('Page title');
      

      Parameters

      • title: string | Title

        The title of the (non-file) page that the wikilink links to.

      • Optionaldisplay: string

        An optional display text for the wikilink.

      Returns Wikilink

      • If the title is invalid.
      • If the title is a file title. To objectify a '[[File:...]]' wikilink, use FileWikilink instead.

    Methods

    • Checks if the given object is an instance of the specified wikilink-related class.

      This method is an alternative of the instanceof operator, which cannot be used for non-exported classes.

      Example:

      const [foo] = new mwbot.Wikitext('[[Foo]]').parseWikilinks();
      foo instanceof mwbot.Wikilink; // true
      mwbot.Wikilink.is(foo, 'ParsedWikilink'); // true
      foo instanceof mwbot.FileWikilink; // false
      mwbot.Wikilink.is(foo, 'ParsedFileWikilink'); // false
      foo instanceof mwbot.RawWikilink; // false
      mwbot.Wikilink.is(foo, 'ParsedRawWikilink'); // false

      Be noted about the hierarchies of the wikilink-related classes:

      Type Parameters

      • T extends keyof WikilinkTypeMap

        The type of wikilink to check for. Must be one of 'Wikilink', 'ParsedWikilink', 'FileWikilink', 'ParsedFileWikilink', 'RawWikilink', or 'ParsedRawWikilink'.

      Parameters

      • obj: unknown

        The object to check.

      • type: T

        The wikilink type to compare against.

      Returns obj is WikilinkTypeMap[T]

      true if obj is an instance of the specified wikilink class, otherwise false.

      If an invalid type is provided.