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

fix: Type exports correctly #2207

Merged
merged 2 commits into from
May 29, 2024
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
33 changes: 23 additions & 10 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type NodemonEventHandler =
export type NodemonEventHandler =
| 'start'
| 'crash'
| 'exit'
Expand All @@ -10,7 +10,7 @@ type NodemonEventHandler =
| 'stdout'
| 'stderr';

type NodemonEventListener = {
export type NodemonEventListener = {
on(event: 'start' | 'crash' | 'readable', listener: () => void): Nodemon;
on(event: 'log', listener: (e: NodemonEventLog) => void): Nodemon;
on(event: 'stdout' | 'stderr', listener: (e: string) => void): Nodemon;
Expand All @@ -23,7 +23,7 @@ type NodemonEventListener = {
): Nodemon;
};

type Nodemon = {
export type Nodemon = {
(options?: NodemonSettings): Nodemon;
on(event: 'start' | 'crash', listener: () => void): Nodemon;
on(event: 'log', listener: (e: NodemonEventLog) => void): Nodemon;
Expand Down Expand Up @@ -75,7 +75,7 @@ type Nodemon = {
config: NodemonSettings;
};

type NodemonEventLog = {
export type NodemonEventLog = {
/**
detail*: what you get with nodemon --verbose.
status: subprocess starting, restarting.
Expand All @@ -89,20 +89,20 @@ type NodemonEventLog = {
colour: String;
};

interface NodemonEventRestart {
export interface NodemonEventRestart {
matched?: {
result: string[];
total: number;
};
}

type NodemonEventQuit = 143 | 130;
type NodemonEventExit = number;
export type NodemonEventQuit = 143 | 130;
export type NodemonEventExit = number;

// TODO: Define the type of NodemonEventConfig
type NodemonEventConfig = any;
export type NodemonEventConfig = any;

interface NodemonSettings {
export interface NodemonConfig {
/* restartable defaults to "rs" as a string the user enters */
restartable?: false | String;
colours?: Boolean;
Expand All @@ -117,10 +117,23 @@ interface NodemonSettings {
watchOptions?: WatchOptions;
}

interface WatchOptions {
export interface NodemonSettings extends NodemonConfig {
script: string;
ext?: string; // "js,mjs" etc (should really support an array of strings, but I don't think it does right now)
events?: { [key: string]: string };
env?: { [key: string]: string };
exec?: string; // node, python, etc
execArgs?: string[]; // args passed to node, etc,
nodeArgs?: string[]; // args passed to node, etc,
delay?: number;
}

export interface WatchOptions {
ignorePermissionErrors: boolean;
ignored: string;
persistent: boolean;
usePolling: boolean;
interval: number;
}

export default function nodemon(settings: NodemonSettings): Nodemon;
Loading