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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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 own property names are property names 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. * Returns an object whose properties have the value 'true'
  77. * when they will be absent when used in a 'with' statement.
  78. */
  79. [Symbol.unscopables](): {
  80. copyWithin: boolean;
  81. entries: boolean;
  82. fill: boolean;
  83. find: boolean;
  84. findIndex: boolean;
  85. keys: boolean;
  86. values: boolean;
  87. };
  88. }
  89. interface Date {
  90. /**
  91. * Converts a Date object to a string.
  92. */
  93. [Symbol.toPrimitive](hint: "default"): string;
  94. /**
  95. * Converts a Date object to a string.
  96. */
  97. [Symbol.toPrimitive](hint: "string"): string;
  98. /**
  99. * Converts a Date object to a number.
  100. */
  101. [Symbol.toPrimitive](hint: "number"): number;
  102. /**
  103. * Converts a Date object to a string or number.
  104. *
  105. * @param hint The strings "number", "string", or "default" to specify what primitive to return.
  106. *
  107. * @throws {TypeError} If 'hint' was given something other than "number", "string", or "default".
  108. * @returns A number if 'hint' was "number", a string if 'hint' was "string" or "default".
  109. */
  110. [Symbol.toPrimitive](hint: string): string | number;
  111. }
  112. interface Map<K, V> {
  113. readonly [Symbol.toStringTag]: string;
  114. }
  115. interface WeakMap<K extends object, V> {
  116. readonly [Symbol.toStringTag]: string;
  117. }
  118. interface Set<T> {
  119. readonly [Symbol.toStringTag]: string;
  120. }
  121. interface WeakSet<T extends object> {
  122. readonly [Symbol.toStringTag]: string;
  123. }
  124. interface JSON {
  125. readonly [Symbol.toStringTag]: string;
  126. }
  127. interface Function {
  128. /**
  129. * Determines whether the given value inherits from this function if this function was used
  130. * as a constructor function.
  131. *
  132. * A constructor function can control which objects are recognized as its instances by
  133. * 'instanceof' by overriding this method.
  134. */
  135. [Symbol.hasInstance](value: any): boolean;
  136. }
  137. interface GeneratorFunction {
  138. readonly [Symbol.toStringTag]: string;
  139. }
  140. interface Math {
  141. readonly [Symbol.toStringTag]: string;
  142. }
  143. interface Promise<T> {
  144. readonly [Symbol.toStringTag]: string;
  145. }
  146. interface PromiseConstructor {
  147. readonly [Symbol.species]: PromiseConstructor;
  148. }
  149. interface RegExp {
  150. /**
  151. * Matches a string with this regular expression, and returns an array containing the results of
  152. * that search.
  153. * @param string A string to search within.
  154. */
  155. [Symbol.match](string: string): RegExpMatchArray | null;
  156. /**
  157. * Replaces text in a string, using this regular expression.
  158. * @param string A String object or string literal whose contents matching against
  159. * this regular expression will be replaced
  160. * @param replaceValue A String object or string literal containing the text to replace for every
  161. * successful match of this regular expression.
  162. */
  163. [Symbol.replace](string: string, replaceValue: string): string;
  164. /**
  165. * Replaces text in a string, using this regular expression.
  166. * @param string A String object or string literal whose contents matching against
  167. * this regular expression will be replaced
  168. * @param replacer A function that returns the replacement text.
  169. */
  170. [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string;
  171. /**
  172. * Finds the position beginning first substring match in a regular expression search
  173. * using this regular expression.
  174. *
  175. * @param string The string to search within.
  176. */
  177. [Symbol.search](string: string): number;
  178. /**
  179. * Returns an array of substrings that were delimited by strings in the original input that
  180. * match against this regular expression.
  181. *
  182. * If the regular expression contains capturing parentheses, then each time this
  183. * regular expression matches, the results (including any undefined results) of the
  184. * capturing parentheses are spliced.
  185. *
  186. * @param string string value to split
  187. * @param limit if not undefined, the output array is truncated so that it contains no more
  188. * than 'limit' elements.
  189. */
  190. [Symbol.split](string: string, limit?: number): string[];
  191. }
  192. interface RegExpConstructor {
  193. readonly [Symbol.species]: RegExpConstructor;
  194. }
  195. interface String {
  196. /**
  197. * Matches a string or an object that supports being matched against, and returns an array
  198. * containing the results of that search, or null if no matches are found.
  199. * @param matcher An object that supports being matched against.
  200. */
  201. match(matcher: { [Symbol.match](string: string): RegExpMatchArray | null; }): RegExpMatchArray | null;
  202. /**
  203. * Replaces first match with string or all matches with RegExp.
  204. * @param searchValue A string or RegExp search value.
  205. * @param replaceValue A string containing the text to replace for match.
  206. */
  207. replace(searchValue: { [Symbol.replace](string: string, replaceValue: string): string; }, replaceValue: string): string;
  208. /**
  209. * Replaces text in a string, using an object that supports replacement within a string.
  210. * @param searchValue A object can search for and replace matches within a string.
  211. * @param replacer A function that returns the replacement text.
  212. */
  213. replace(searchValue: { [Symbol.replace](string: string, replacer: (substring: string, ...args: any[]) => string): string; }, replacer: (substring: string, ...args: any[]) => string): string;
  214. /**
  215. * Finds the first substring match in a regular expression search.
  216. * @param searcher An object which supports searching within a string.
  217. */
  218. search(searcher: { [Symbol.search](string: string): number; }): number;
  219. /**
  220. * Split a string into substrings using the specified separator and return them as an array.
  221. * @param splitter An object that can split a string.
  222. * @param limit A value used to limit the number of elements returned in the array.
  223. */
  224. split(splitter: { [Symbol.split](string: string, limit?: number): string[]; }, limit?: number): string[];
  225. }
  226. interface ArrayBuffer {
  227. readonly [Symbol.toStringTag]: string;
  228. }
  229. interface DataView {
  230. readonly [Symbol.toStringTag]: string;
  231. }
  232. interface Int8Array {
  233. readonly [Symbol.toStringTag]: "Int8Array";
  234. }
  235. interface Uint8Array {
  236. readonly [Symbol.toStringTag]: "Uint8Array";
  237. }
  238. interface Uint8ClampedArray {
  239. readonly [Symbol.toStringTag]: "Uint8ClampedArray";
  240. }
  241. interface Int16Array {
  242. readonly [Symbol.toStringTag]: "Int16Array";
  243. }
  244. interface Uint16Array {
  245. readonly [Symbol.toStringTag]: "Uint16Array";
  246. }
  247. interface Int32Array {
  248. readonly [Symbol.toStringTag]: "Int32Array";
  249. }
  250. interface Uint32Array {
  251. readonly [Symbol.toStringTag]: "Uint32Array";
  252. }
  253. interface Float32Array {
  254. readonly [Symbol.toStringTag]: "Float32Array";
  255. }
  256. interface Float64Array {
  257. readonly [Symbol.toStringTag]: "Float64Array";
  258. }
  259. interface ArrayConstructor {
  260. readonly [Symbol.species]: ArrayConstructor;
  261. }
  262. interface MapConstructor {
  263. readonly [Symbol.species]: MapConstructor;
  264. }
  265. interface SetConstructor {
  266. readonly [Symbol.species]: SetConstructor;
  267. }
  268. interface ArrayBufferConstructor {
  269. readonly [Symbol.species]: ArrayBufferConstructor;
  270. }