/** * @fileoverview this is a hand-written, non-exhaustive d.ts file for closure library's base.js. * Instead of automatically generating this using clutz, we provide here a few definitions * written in hand, as in many cases one can refine type information than what clutz provides. * - closure annotation {Object} incompatible with Typescript: dict-type object cannot be assigned * to Object in Typescript. * - One may use type predicates to provide a better user experience */ declare namespace goog { /** * Reference to the global object. * https://www.ecma-international.org/ecma-262/9.0/index.html#sec-global-object * * More info on this implementation here: * https://docs.google.com/document/d/1NAeW4Wk7I7FV0Y2tcUFvQdGMc89k2vdgSXInw8_nvCI/edit * * @const * @suppress {undefinedVars} self won't be referenced unless `this` is falsy. * @type {!Global} */ const global: typeof globalThis; /** * Handles strings that are intended to be used as CSS class names. * * This function works in tandem with @see goog.setCssNameMapping. * * Without any mapping set, the arguments are simple joined with a hyphen and * passed through unaltered. * * When there is a mapping, there are two possible styles in which these * mappings are used. In the BY_PART style, each part (i.e. in between hyphens) * of the passed in css name is rewritten according to the map. In the BY_WHOLE * style, the full css name is looked up in the map directly. If a rewrite is * not specified by the map, the compiler will output a warning. * * When the mapping is passed to the compiler, it will replace calls to * goog.getCssName with the strings from the mapping, e.g. * var x = goog.getCssName('foo'); * var y = goog.getCssName(this.baseClass, 'active'); * becomes: * var x = 'foo'; * var y = this.baseClass + '-active'; * * If one argument is passed it will be processed, if two are passed only the * modifier will be processed, as it is assumed the first argument was generated * as a result of calling goog.getCssName. * * @param {string} className The class name. * @param {string=} opt_modifier A modifier to be appended to the class name. * @return {string} The class name or the concatenation of the class name and * the modifier. */ function getCssName(className: string, opt_modifier?: string): string /** * Sets the map to check when returning a value from goog.getCssName(). Example: *
* goog.setCssNameMapping({
* "goog": "a",
* "disabled": "b",
* });
*
* var x = goog.getCssName('goog');
* // The following evaluates to: "a a-b".
* goog.getCssName('goog') + ' ' + goog.getCssName(x, 'disabled')
*
* When declared as a map of string literals to string literals, the JSCompiler
* will replace all calls to goog.getCssName() using the supplied map if the
* --process_closure_primitives flag is set.
*
* @param {!Object} mapping A map of strings to strings where keys are possible
* arguments to goog.getCssName() and values are the corresponding values
* that should be returned.
* @param {string=} opt_style The style of css name mapping. There are two valid
* options: 'BY_PART', and 'BY_WHOLE'.
* @see goog.getCssName for a description.
*/
function setCssNameMapping(mapping: {[key: string]: string}, opt_style: 'BY_PART' | 'BY_WHOLE'): void
/**
* Gets a localized message.
*
* This function is a compiler primitive. If you give the compiler a localized
* message bundle, it will replace the string at compile-time with a localized
* version, and expand goog.getMsg call to a concatenated string.
*
* Messages must be initialized in the form:
*
* var MSG_NAME = goog.getMsg('Hello {$placeholder}', {'placeholder': 'world'});
*
*
* This function produces a string which should be treated as plain text. Use
* {@link goog.html.SafeHtmlFormatter} in conjunction with goog.getMsg to
* produce SafeHtml.
*
* @param {string} str Translatable string, places holders in the form {$foo}.
* @param {Objectvar x = goog.getMsgWithFallback(MSG_A, MSG_B);
* where MSG_A and MSG_B were initialized with goog.getMsg.
*
* @param {string} a The preferred message.
* @param {string} b The fallback message.
* @return {string} The best translated message.
*/
function getMsgWithFallback(a: string, b: string): string
/**
* Exposes an unobfuscated global namespace path for the given object.
* Note that fields of the exported object *will* be obfuscated, unless they are
* exported in turn via this function or goog.exportProperty.
*
* Also handy for making public items that are defined in anonymous closures.
*
* ex. goog.exportSymbol('public.path.Foo', Foo);
*
* ex. goog.exportSymbol('public.path.Foo.staticFunction', Foo.staticFunction);
* public.path.Foo.staticFunction();
*
* ex. goog.exportSymbol('public.path.Foo.prototype.myMethod',
* Foo.prototype.myMethod);
* new public.path.Foo().myMethod();
*
* @param {string} publicPath Unobfuscated name to export.
* @param {*} object Object the name should point to.
* @param {Object=} opt_objectToExportTo The object to add the path to; default
* is goog.global.
*/
function exportSymbol(publicPath: string, object: any, opt_objectToExportTo?: {}): void
/**
* Exports a property unobfuscated into the object's namespace.
* ex. goog.exportProperty(Foo, 'staticFunction', Foo.staticFunction);
* ex. goog.exportProperty(Foo.prototype, 'myMethod', Foo.prototype.myMethod);
* @param {Object} object Object whose static property is being exported.
* @param {string} publicName Unobfuscated name to export.
* @param {*} symbol Object the name should point to.
*/
function exportProperty(object: {}, publicName: string, symbol: any): void
/**
* Defines a named value. In uncompiled mode, the value is retrieved from
* CLOSURE_DEFINES or CLOSURE_UNCOMPILED_DEFINES if the object is defined and
* has the property specified, and otherwise used the defined defaultValue.
* When compiled the default can be overridden using the compiler options or the
* value set in the CLOSURE_DEFINES object. Returns the defined value so that it
* can be used safely in modules. Note that the value type MUST be either
* boolean, number, or string.
*
* @param {string} name The distinguished name to provide.
* @param {T} defaultValue
* @return {T} The defined value.
* @template T
*/
function define