lib.es2015.symbol.wellknown.d.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. /*! *****************************************************************************
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  4. this file except in compliance with the License. You may obtain a copy of the
  5. License at http://www.apache.org/licenses/LICENSE-2.0
  6. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  8. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  9. MERCHANTABLITY OR NON-INFRINGEMENT.
  10. See the Apache Version 2.0 License for specific language governing permissions
  11. and limitations under the License.
  12. ***************************************************************************** */
  13. /// <reference no-default-lib="true"/>
  14. /// <reference lib="es2015.symbol" />
  15. interface SymbolConstructor {
  16. /**
  17. * A method that determines if a constructor object recognizes an object as one of the
  18. * constructor’s instances. Called by the semantics of the instanceof operator.
  19. */
  20. readonly hasInstance: unique symbol;
  21. /**
  22. * A Boolean value that if true indicates that an object should flatten to its array elements
  23. * by Array.prototype.concat.
  24. */
  25. readonly isConcatSpreadable: unique symbol;
  26. /**
  27. * A regular expression method that matches the regular expression against a string. Called
  28. * by the String.prototype.match method.
  29. */
  30. readonly match: unique symbol;
  31. /**
  32. * A regular expression method that replaces matched substrings of a string. Called by the
  33. * String.prototype.replace method.
  34. */
  35. readonly replace: unique symbol;
  36. /**
  37. * A regular expression method that returns the index within a string that matches the
  38. * regular expression. Called by the String.prototype.search method.
  39. */
  40. readonly search: unique symbol;
  41. /**
  42. * A function valued property that is the constructor function that is used to create
  43. * derived objects.
  44. */
  45. readonly species: unique symbol;
  46. /**
  47. * A regular expression method that splits a string at the indices that match the regular
  48. * expression. Called by the String.prototype.split method.
  49. */
  50. readonly split: unique symbol;
  51. /**
  52. * A method that converts an object to a corresponding primitive value.
  53. * Called by the ToPrimitive abstract operation.
  54. */
  55. readonly toPrimitive: unique symbol;
  56. /**
  57. * A String value that is used in the creation of the default string description of an object.
  58. * Called by the built-in method Object.prototype.toString.
  59. */
  60. readonly toStringTag: unique symbol;
  61. /**
  62. * An Object whose truthy properties are properties that are excluded from the 'with'
  63. * environment bindings of the associated objects.
  64. */
  65. readonly unscopables: unique symbol;
  66. }
  67. interface Symbol {
  68. /**
  69. * Converts a Symbol object to a symbol.
  70. */
  71. [Symbol.toPrimitive](hint: string): symbol;
  72. readonly [Symbol.toStringTag]: string;
  73. }
  74. interface Array<T> {
  75. /**
  76. * Is an object whose properties have the value 'true'
  77. * when they will be absent when used in a 'with' statement.
  78. */
  79. readonly [Symbol.unscopables]: {
  80. [K in keyof any[]]?: boolean;
  81. };
  82. }
  83. interface ReadonlyArray<T> {
  84. /**
  85. * Is an object whose properties have the value 'true'
  86. * when they will be absent when used in a 'with' statement.
  87. */
  88. readonly [Symbol.unscopables]: {
  89. [K in keyof readonly any[]]?: boolean;
  90. };
  91. }
  92. interface Date {
  93. /**
  94. * Converts a Date object to a string.
  95. */
  96. [Symbol.toPrimitive](hint: "default"): string;
  97. /**
  98. * Converts a Date object to a string.
  99. */
  100. [Symbol.toPrimitive](hint: "string"): string;
  101. /**
  102. * Converts a Date object to a number.
  103. */
  104. [Symbol.toPrimitive](hint: "number"): number;
  105. /**
  106. * Converts a Date object to a string or number.
  107. *
  108. * @param hint The strings "number", "string", or "default" to specify what primitive to return.
  109. *
  110. * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default".
  111. * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default".
  112. */
  113. [Symbol.toPrimitive](hint: string): string | number;
  114. }
  115. interface Map<K, V> {
  116. readonly [Symbol.toStringTag]: string;
  117. }
  118. interface WeakMap<K extends WeakKey, V> {
  119. readonly [Symbol.toStringTag]: string;
  120. }
  121. interface Set<T> {
  122. readonly [Symbol.toStringTag]: string;
  123. }
  124. interface WeakSet<T extends WeakKey> {
  125. readonly [Symbol.toStringTag]: string;
  126. }
  127. interface JSON {
  128. readonly [Symbol.toStringTag]: string;
  129. }
  130. interface Function {
  131. /**
  132. * Determines whether the given value inherits from this function if this function was used
  133. * as a constructor function.
  134. *
  135. * A constructor function can control which objects are recognized as its instances by
  136. * 'instanceof' by overriding this method.
  137. */
  138. [Symbol.hasInstance](value: any): boolean;
  139. }
  140. interface GeneratorFunction {
  141. readonly [Symbol.toStringTag]: string;
  142. }
  143. interface Math {
  144. readonly [Symbol.toStringTag]: string;
  145. }
  146. interface Promise<T> {
  147. readonly [Symbol.toStringTag]: string;
  148. }
  149. interface PromiseConstructor {
  150. readonly [Symbol.species]: PromiseConstructor;
  151. }
  152. interface RegExp {
  153. /**
  154. * Matches a string with this regular expression, and returns an array containing the results of
  155. * that search.
  156. * @param string A string to search within.
  157. */
  158. [Symbol.match](string: string): RegExpMatchArray | null;
  159. /**
  160. * Replaces text in a string, using this regular expression.
  161. * @param string A String object or string literal whose contents matching against
  162. * this regular expression will be replaced
  163. * @param replaceValue A String object or string literal containing the text to replace for every
  164. * successful match of this regular expression.
  165. */
  166. [Symbol.replace](string: string, replaceValue: string): string;
  167. /**
  168. * Replaces text in a string, using this regular expression.
  169. * @param string A String object or string literal whose contents matching against
  170. * this regular expression will be replaced
  171. * @param replacer A function that returns the replacement text.
  172. */
  173. [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string;
  174. /**
  175. * Finds the position beginning first substring match in a regular expression search
  176. * using this regular expression.
  177. *
  178. * @param string The string to search within.
  179. */
  180. [Symbol.search](string: string): number;
  181. /**
  182. * Returns an array of substrings that were delimited by strings in the original input that
  183. * match against this regular expression.
  184. *
  185. * If the regular expression contains capturing parentheses, then each time this
  186. * regular expression matches, the results (including any undefined results) of the
  187. * capturing parentheses are spliced.
  188. *
  189. * @param string string value to split
  190. * @param limit if not undefined, the output array is truncated so that it contains no more
  191. * than 'limit' elements.
  192. */
  193. [Symbol.split](string: string, limit?: number): string[];
  194. }
  195. interface RegExpConstructor {
  196. readonly [Symbol.species]: RegExpConstructor;
  197. }
  198. interface String {
  199. /**
  200. * Matches a string or an object that supports being matched against, and returns an array
  201. * containing the results of that search, or null if no matches are found.
  202. * @param matcher An object that supports being matched against.
  203. */
  204. match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null;
  205. /**
  206. * Passes a string and {@linkcode replaceValue} to the `[Symbol.replace]` method on {@linkcode searchValue}. This method is expected to implement its own replacement algorithm.
  207. * @param searchValue An object that supports searching for and replacing matches within a string.
  208. * @param replaceValue The replacement text.
  209. */
  210. replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string;
  211. /**
  212. * Replaces text in a string, using an object that supports replacement within a string.
  213. * @param searchValue A object can search for and replace matches within a string.
  214. * @param replacer A function that returns the replacement text.
  215. */
  216. replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string;
  217. /**
  218. * Finds the first substring match in a regular expression search.
  219. * @param searcher An object which supports searching within a string.
  220. */
  221. search(searcher: { [Symbol.search](string: string): number; }): number;
  222. /**
  223. * Split a string into substrings using the specified separator and return them as an array.
  224. * @param splitter An object that can split a string.
  225. * @param limit A value used to limit the number of elements returned in the array.
  226. */
  227. split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[];
  228. }
  229. interface ArrayBuffer {
  230. readonly [Symbol.toStringTag]: string;
  231. }
  232. interface DataView {
  233. readonly [Symbol.toStringTag]: string;
  234. }
  235. interface Int8Array {
  236. readonly [Symbol.toStringTag]: "Int8Array";
  237. }
  238. interface Uint8Array {
  239. readonly [Symbol.toStringTag]: "Uint8Array";
  240. }
  241. interface Uint8ClampedArray {
  242. readonly [Symbol.toStringTag]: "Uint8ClampedArray";
  243. }
  244. interface Int16Array {
  245. readonly [Symbol.toStringTag]: "Int16Array";
  246. }
  247. interface Uint16Array {
  248. readonly [Symbol.toStringTag]: "Uint16Array";
  249. }
  250. interface Int32Array {
  251. readonly [Symbol.toStringTag]: "Int32Array";
  252. }
  253. interface Uint32Array {
  254. readonly [Symbol.toStringTag]: "Uint32Array";
  255. }
  256. interface Float32Array {
  257. readonly [Symbol.toStringTag]: "Float32Array";
  258. }
  259. interface Float64Array {
  260. readonly [Symbol.toStringTag]: "Float64Array";
  261. }
  262. interface ArrayConstructor {
  263. readonly [Symbol.species]: ArrayConstructor;
  264. }
  265. interface MapConstructor {
  266. readonly [Symbol.species]: MapConstructor;
  267. }
  268. interface SetConstructor {
  269. readonly [Symbol.species]: SetConstructor;
  270. }
  271. interface ArrayBufferConstructor {
  272. readonly [Symbol.species]: ArrayBufferConstructor;
  273. }