In Deno 2.1.7 I stumbled on Deno.Stdin, Deno.FsFile but using these types fails to pass check
I can "run" the following code it doesn't pass check or compile. What is the right way to approach this?
(file is named foo.ts).
Running
deno run --allow-read foo.ts
works fine as does running the main function interactively in the REPL. On the other hand deno check foo.ts
returns the following message. How should I be import Stdin
ad FsFile
to allow it to be compiled?
2 Replies
in the case of FsFile, its part of the deno namespace, so the type would be
Deno.FsFile
for Stdin, there is no stdin type, so you would have to do typeof Deno.stdin
I changed the line
let input: Stdin | FsFile;
to let input: Deno.FsFile | any;
The typeof(Deno.stdin)
return "object" but that causes an error for lacking the readable
method used later. "any" seems pretty ugly but it does work. Thanks for the help!