deno
deno copied to clipboard
`Iterator` proposal type declarations are missing
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
- Clone the
main
branch of this repository - Run
deno test
at the root of the project - 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
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
Thanks for the fix with Temporal
, wish the error was a bit more helpful.
Upstream: https://github.com/microsoft/TypeScript/pull/58222
I get a lot of type errors like Property 'map' does not exist on type 'IterableIterator<x>'
. Is that the same issue?
Is it likely to be resolved soon, now that https://github.com/microsoft/TypeScript/pull/58222 is merged?
TypeScript 5.6 supports Stage 3 Iterator Helpers types, so just wait for it to be imported to Deno. That will probably take at least a few months, as TypeScript code needs to be bundled and patched.
I get a lot of type errors like Property 'map' does not exist on type 'IterableIterator
' . Is that the same issue?
Yes, an IteratorObject<T, TReturn = unknown, TNext = unknown>
interface is introduced and a map
method is defined for it.
OK, that's great news thanks!