lib.es2015.generator.d.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.iterable" />
  15. interface Generator<T = unknown, TReturn = any, TNext = unknown> extends Iterator<T, TReturn, TNext> {
  16. // NOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
  17. next(...args: [] | [TNext]): IteratorResult<T, TReturn>;
  18. return(value: TReturn): IteratorResult<T, TReturn>;
  19. throw(e: any): IteratorResult<T, TReturn>;
  20. [Symbol.iterator](): Generator<T, TReturn, TNext>;
  21. }
  22. interface GeneratorFunction {
  23. /**
  24. * Creates a new Generator object.
  25. * @param args A list of arguments the function accepts.
  26. */
  27. new (...args: any[]): Generator;
  28. /**
  29. * Creates a new Generator object.
  30. * @param args A list of arguments the function accepts.
  31. */
  32. (...args: any[]): Generator;
  33. /**
  34. * The length of the arguments.
  35. */
  36. readonly length: number;
  37. /**
  38. * Returns the name of the function.
  39. */
  40. readonly name: string;
  41. /**
  42. * A reference to the prototype.
  43. */
  44. readonly prototype: Generator;
  45. }
  46. interface GeneratorFunctionConstructor {
  47. /**
  48. * Creates a new Generator function.
  49. * @param args A list of arguments the function accepts.
  50. */
  51. new (...args: string[]): GeneratorFunction;
  52. /**
  53. * Creates a new Generator function.
  54. * @param args A list of arguments the function accepts.
  55. */
  56. (...args: string[]): GeneratorFunction;
  57. /**
  58. * The length of the arguments.
  59. */
  60. readonly length: number;
  61. /**
  62. * Returns the name of the function.
  63. */
  64. readonly name: string;
  65. /**
  66. * A reference to the prototype.
  67. */
  68. readonly prototype: GeneratorFunction;
  69. }