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

    Interface ParsedTemplateStaticPrivate

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

    This class is exclusive to Wikitext.parseTemplates. It represents a well-formed {{template}} markup with a valid title. For the class that represents a malformed {{template}} markup with an invalid title, see RawTemplateStatic.

    This class differs from RawTemplate in that:

    • It extends the Template class.
    • The title property is an instance of Title instead of a string.

    The constructor of this class is inaccessible, and instances can only be referenced in the result of parseTemplates.

    To check if an object is an instance of this class, use TemplateStatic.is.

    Important:

    The instance properties of this class are pseudo-read-only, in the sense that altering them does not affect the behaviour of Wikitext.modifyTemplates.

    interface ParsedTemplateStatic {
        new ParsedTemplateStatic(
            initializer: ParsedTemplateInitializer,
            options?: ParsedTemplateOptions,
        ): ParsedTemplate;
        is<T extends keyof TemplateTypeMap>(
            obj: unknown,
            type: T,
        ): obj is TemplateTypeMap[T];
    }

    Hierarchy

    Index

    Constructors

    Methods

    Constructors

    • Private

      Parameters

      • initializer: ParsedTemplateInitializer
      • Optionaloptions: ParsedTemplateOptions

      Returns ParsedTemplate

    Methods

    • Checks if the given object is an instance of the specified template-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}}').parseTemplates();
      foo instanceof mwbot.Template; // true
      mwbot.Template.is(foo, 'ParsedTemplate'); // true
      mwbot.Template.is(foo, 'RawTemplate'); // false
      foo instanceof mwbot.ParserFunction; // false
      mwbot.Template.is(foo, 'ParsedParserFunction'); // false

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

      Type Parameters

      • T extends keyof TemplateTypeMap

        The type of template to check for. Must be one of 'Template', 'ParsedTemplate', 'RawTemplate', 'ParserFunction', or 'ParsedParserFunction'.

      Parameters

      • obj: unknown

        The object to check.

      • type: T

        The template type to compare against.

      Returns obj is TemplateTypeMap[T]

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

      If an invalid type is provided.