diff --git a/mw/html.d.ts b/mw/html.d.ts new file mode 100644 index 0000000..674d210 --- /dev/null +++ b/mw/html.d.ts @@ -0,0 +1,36 @@ +declare global { + namespace mw { + namespace html { + /** + * Escape a string for HTML. + * Converts special characters to HTML entities. + * @param {string} s The string to escape + * @returns {string} HTML + */ + function escape(s: string): string; + + /** + * Create an HTML element string, with safe escaping. + * @param {string} name The tag name + * @param {{ [key: string]: string }} attrs An object with members mapping element names to values + * @param {string | html.Raw} contents The contents of the element + * @returns {string} HTML + */ + function element( + name: string, + attrs?: Record, + contents?: string | mw.html.Raw + ): string; + + /** + * Wrapper object for raw HTML passed to mw.html.element(). + */ + class Raw { + constructor(value: V); + private value: V; + } + } + } +} + +export {}; diff --git a/mw/index.d.ts b/mw/index.d.ts index fa14918..563355c 100644 --- a/mw/index.d.ts +++ b/mw/index.d.ts @@ -84,12 +84,6 @@ declare global { wgWikibaseItemId: string; }>; - namespace html { - function escape(s: string): string; - - function element(name: string, attrs?: any, contents?: string): string; - } - namespace log { function deprecate( obj: any,