2.14.1 • Published 3 days ago

types-mediawiki-renovate v2.14.1

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
3 days ago

NPM version PRs Welcome

types-mediawiki-renovate

TypeScript definitions for MediaWiki JS interface.

This package covers the functions and classes in the mw global object, as well some jQuery plugins used in MediaWiki core. All commonly used parts of the interface are covered.

Download stats

Usage

To use types from this package, run

pnpm add -D @types/jquery @types/oojs-ui types-mediawiki-renovate

Edit your project's tsconfig.json file so that it includes

"include": [
  "node_modules/types-mediawiki-renovate"
]

You should be all set! mw will be available in the global scope. There is no need to put any import statements in the TypeScript source files.

If you find any errors or have suggestions for more specific typings, please open a PR or file an issue.

mw.config

Types for mw.config are included:

let NS = mw.config.get('wgNamespaceNumber'); // NS gets type number
let pageName = mw.config.get('wgPageName'); // pageName gets type string

mw.config entries added by MediaWiki extensions can also be used but their type is not known, so they need to be declare:

interface MediaWikiConfigMap {
	pageTriageNamespaces: number[];
}
let namespaces = mw.config.get('pageTriageNamespaces');

or explicitly cast:

let namespaces = mw.config.get('pageTriageNamespaces') as number[];

(mw.config.get("pageTriageNamespaces") gets the type unknown without using the interface merging or a cast.)

The optional values ​​of the return value of mw.config.get("wgAction") can also be extended through MediaWikiConfigMapWgAction like MediaWikiConfigMap.

MediaWiki API parameters

This package also provides typings for API request parameters for the MediaWiki Action API. API endpoints defined in MediaWiki core and by a number of common extensions (the ones enabled on English Wikipedia) are covered. These aren't exported to the global scope, however. For usage, you need to import them. For example:

import type {ApiEditPageParams, ApiParseParams} from 'types-mediawiki/api_params';

Since it is just a type import, it doesn't generate any JavaScript. Hence, such imports can also be used in non-modular applications.

TODO

  • Add doc comments for mw.ForeignStructuredUpload, mw.GallerySlideshow, mw.special.ApiSandbox and mw.jqueryMsg private methods.
2.14.1

3 days ago

2.14.0

3 days ago

2.13.0

11 days ago

2.12.2

26 days ago

2.12.1

1 month ago

2.12.0

2 months ago

2.11.0

2 months ago

2.10.1

2 months ago

2.10.0

3 months ago

2.9.4

3 months ago

2.9.3

3 months ago

2.9.2

3 months ago

2.9.1

3 months ago

2.9.0

3 months ago

2.8.1

3 months ago

2.8.0

3 months ago

2.7.0

4 months ago

2.5.0

4 months ago

2.6.0

4 months ago

2.5.1

4 months ago

2.4.1

4 months ago

2.4.0

4 months ago

2.3.0

5 months ago

2.2.0

5 months ago

2.1.0

5 months ago

2.0.1

6 months ago

2.0.0

6 months ago