denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
93.47k stars 5.18k forks source link

`Iterator` proposal type declarations are missing #23357

Open ben-laird opened 3 months ago

ben-laird commented 3 months ago

Version: Deno 1.42.3

Explanation

Hello! I'm using Deno in experiments with TypeScript to learn more about the language, especially surrounding iterators and bleeding-edge ECMAScript proposals. As of 1.42 I had read that Deno has support for the Temporal API as well as the new Iterator API. When I went to use them in my own code, the language server didn't even recognize the Iterator namespace, and running any code with the Temporal namespace with Deno throws a ReferenceError. Here is a link to a minimal reproduction of the issue.

Reproduction

  1. Clone the main branch of this repository
  2. Run deno test at the root of the project
  3. Observe thrown errors:
    • TS2693 [ERROR]: 'Iterator' only refers to a type, but is being used as a value here.
    • When the offending code of the previous error is commented out, error: ReferenceError: Temporal is not defined

Details

Output of deno --version:

deno 1.42.3 (release, aarch64-apple-darwin)
v8 12.3.219.9
typescript 5.4.3
jtoppine commented 3 months ago

Temporal is still an unstable API, to use it you need to run Deno with --unstable-temporal command line option. (seems like it's missing from the manual: https://docs.deno.com/runtime/manual/tools/unstable_flags )

Not sure about Iterator

ben-laird commented 3 months ago

Thanks for the fix with Temporal, wish the error was a bit more helpful.

petamoriken commented 1 month ago

Upstream: https://github.com/microsoft/TypeScript/pull/58222