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

Update typescript types #57

Merged
merged 3 commits into from
Aug 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 48 additions & 4 deletions node-file-trace.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,58 @@
interface NodeFileTraceOptions {
interface Stats {
isFile(): boolean;
isDirectory(): boolean;
isBlockDevice(): boolean;
isCharacterDevice(): boolean;
isSymbolicLink(): boolean;
isFIFO(): boolean;
isSocket(): boolean;
dev: number;
ino: number;
mode: number;
nlink: number;
uid: number;
gid: number;
rdev: number;
size: number;
blksize: number;
blocks: number;
atimeMs: number;
mtimeMs: number;
ctimeMs: number;
birthtimeMs: number;
atime: Date;
mtime: Date;
ctime: Date;
birthtime: Date;
}

export interface NodeFileTraceOptions {
base?: string;
ignore?: string | string[] | ((path: string) => boolean);
ts?: boolean;
log?: boolean;
mixedModules?: boolean;
readFile?: (path: string) => Buffer | string | null;
stat?: (path: string) => Object | null;
stat?: (path: string) => Stats | null;
readlink?: (path: string) => string | null;
}

declare function NodeFileTrace (files: string[], opts: NodeFileTraceOptions): Promise<{ fileList: string[], esmFileList: string[] }>;
export interface NodeFileTraceReasons {
[fileName: string]: {
type: string;
ignored: boolean;
parents: string[];
};
}

export interface NodeFileTraceResult {
fileList: string[];
esmFileList: string[];
reasons: NodeFileTraceReasons;
AndyBitz marked this conversation as resolved.
Show resolved Hide resolved
warnings: Error[];
}

export = NodeFileTrace;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this changed to default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've used export = before, then linked it and typescript complained when I've tried to build a package

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe esModuleInterop should take care of it (I think it supports both syntax options to export). But if it was failing in @now/next, then we can change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, it failed in @now/next

export default function NodeFileTrace(
files: string[],
opts: NodeFileTraceOptions
): Promise<NodeFileTraceResult>;