Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type of WalkEntry does not include isFile, isDirectory, isSymlink #27884

Open
johndeighan opened this issue Jan 30, 2025 · 1 comment
Open

type of WalkEntry does not include isFile, isDirectory, isSymlink #27884

johndeighan opened this issue Jan 30, 2025 · 1 comment
Labels
question a question about the use of Deno

Comments

@johndeighan
Copy link

$ deno --version
deno 2.1.8 (stable, release, x86_64-pc-windows-msvc)
v8 13.0.245.12-rusty
typescript 5.6.2

I have the following code:

for (const h of expandGlobSync('**')) {
	console.dir(h)
}

which prints out the following (truncated):

{
  path: "C:\\Users\\johnd\\utils\\test\\llutils\\file2.txt",
  name: "file2.txt",
  isFile: true,
  isDirectory: false,
  isSymlink: false
}
{
  path: "C:\\Users\\johnd\\utils\\test\\llutils\\file3.flags.txt",
  name: "file3.flags.txt",
  isFile: true,
  isDirectory: false,
  isSymlink: false
}

Note that this is JS code - there's no type checking being done.
The objects being printed are of type WalkEntry. However, the documentation for WalkEntry only lists the 'path' key as existing an a WalkEntry.

That may just sound like a bug in the documentation, but here is my situation. I'm using a language called civet, which is CoffeeScript-like, but handles TypeScript syntax. Consider the following civet code:

import {expandGlobSync} from '@std/fs/expand-glob'
for (const h of expandGlobSync('**/*.txt')) {
	console.log(h.isFile);
	}

When I attempt to type check this file, using the command civet --typecheck temp.civet, I get the following error:

test/temp.civet.tsx:3:16 - error TS2339: Property 'isFile' does not exist on type 'WalkEntry'.

3  console.log(h.isFile);
                 ~~~~~~

I'm certainly not asking for you to support civet, but I can't help believing that you're doing something pretty funky with the WalkEntry type definition for civet to not realize that it includes the keys isFile, isDirectory, isSynlink, and probably name also. Somehow, though, it seems that Deno realizes that those fields are there.

@bartlomieju
Copy link
Member

This code type checks fine in Deno (deno check main.ts). This might be a bug in the library you are using.

Reading docs on WalkEntry: https://jsr.io/@std/fs/doc/expand-glob/~/WalkEntry one can see that it extends Deno.DirEntry which contains all these properties.

@marvinhagemeister marvinhagemeister added the question a question about the use of Deno label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question a question about the use of Deno
Projects
None yet
Development

No branches or pull requests

3 participants