Reputation: 151
Running deno with bundle fails with the following error:
error: TS2339 [ERROR]: Property 'getIterator' does not exist on type 'ReadableStream<R>'.
return res.readable.getIterator();
~~~~~~~~~~~
at https://deno.land/[email protected]/async/pool.ts:45:23
tsconfig
{
"compilerOptions": {
"lib": [
"deno.ns",
"dom",
"dom.iterable"
],
"plugins": [
{
"name": "typescript-deno-plugin"
}
]
}
}
Running commnad.
$ deno bundle -c tsconfig.json app.ts app.js
Please let me know.
Upvotes: 3
Views: 1479
Reputation: 11
This solution work for me, declare getIterator as a global interface.
declare global {
interface ReadableStream<R> {
getIterator(): any
}
}
Upvotes: 0
Reputation: 36
I'm not sure if there is one true cause for this issue, but in my case I received this error when trying to import the "v4" UUID package from the Deno std lib, and I did so with a dependency that resolved transitively (in two or more steps). In my case, I decided for my project to re-export all dependencies in a deps.ts
file at my project root:
[...]
// provide UUID from std lib
export {
v4
} from "https://deno.land/[email protected]/uuid/mod.ts";
[...]
...and then later, in a script destined for the client-side, I imported that module via relative path and tried to use it:
// this fails to compile with OP's error
import { v4 } from "../deps.ts";
[...]
const myNewUUID = v4.generate();
have the consuming module import the external module without an indirect reference (by URL):
// this seems to compile and work OK
import { v4 } from "https://deno.land/[email protected]/uuid/mod.ts";
[...]
const myNewUUID = v4.generate();
I haven't experienced this issue with other std modules, and curiously, this module resolution methodology seems to fail even when the modules from the deps.ts
are reloaded with deno cache --reload deps.ts
- they still fail to resolve with the above error. So I'm unsure if this issue is isolated to the v4 UUID package, or might happen with other modules.
If anyone has any additional info on why this import strategy throws such a convoluted error,I'd love to hear it. (My guess is a bug in the Deno.bundle implementation?) For now, this workaround seems reasonable enough though.
Off-topic note for OP: You've included libraries "dom" and "deno.ns" in your tsconfig.json, so per the documentation you should also provide the target JS level, e.g. "es2018" (see: "Don't forget to include the JavaScript library")
Upvotes: 2