microsoft / microsoft/TypeScript

Generators/Async Generators with TReturn type argument which extends undefined have a return method with a non-optional argument in 3.6.2

Abierto
#33,357 7 comentarios 0 reacciones 1 asignado Ver en GitHub

@rbuckton ya está trabajando en esto.

Desde el 16/9/2019.

Needs Investigation
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

TypeScript Version: 3.6.2

Search Terms:
generator iterator return argument optional required

Code

function *gen(): Generator<number, number | undefined> {
  yield 1;
  return 2;
}

gen().return();

Expected behavior:
The argument passed to the return method should be optional. Not sure if this is possible with typescript.

Actual behavior:

file.ts(6,7): error TS2554: Expected 1 arguments, but got 0.
6 gen().return();
        ~~~~~~~~

  typescript/lib/lib.es2015.generator.d.ts:26:12
    26     return(value: TReturn): IteratorResult<T, TReturn>;
                  ~~~~~~~~~~~~~~
    An argument for 'value' was not provided.

Playground Link:

Playground is not available for 3.6.2

Related Issues:
#30790 Strongly typed iterator PR.
#32682 Other (async) iterator usability issues.
#33239 Trouble implementing async iterator interface in 3.6.2
#33241 Unable to use done property of IteratorResult to narrow types in typescript 3.6.2

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.