-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: add types to help with required nodemon usage #2204
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,126 @@ | ||||||||||
type NodemonEventHandler = | ||||||||||
| 'start' | ||||||||||
| 'crash' | ||||||||||
| 'exit' | ||||||||||
| 'quit' | ||||||||||
| 'restart' | ||||||||||
| 'config:update' | ||||||||||
| 'log' | ||||||||||
| 'readable' | ||||||||||
| 'stdout' | ||||||||||
| 'stderr'; | ||||||||||
|
||||||||||
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; | ||||||||||
on(event: 'restart', listener: (e?: NodemonEventRestart) => void): Nodemon; | ||||||||||
on(event: 'quit', listener: (e?: NodemonEventQuit) => void): Nodemon; | ||||||||||
on(event: 'exit', listener: (e?: NodemonEventExit) => void): Nodemon; | ||||||||||
on( | ||||||||||
event: 'config:update', | ||||||||||
listener: (e?: NodemonEventConfig) => void | ||||||||||
): Nodemon; | ||||||||||
}; | ||||||||||
|
||||||||||
type Nodemon = { | ||||||||||
(options?: NodemonSettings): Nodemon; | ||||||||||
on(event: 'start' | 'crash', listener: () => void): Nodemon; | ||||||||||
on(event: 'log', listener: (e: NodemonEventLog) => void): Nodemon; | ||||||||||
on(event: 'restart', listener: (e?: NodemonEventRestart) => void): Nodemon; | ||||||||||
on(event: 'quit', listener: (e?: NodemonEventQuit) => void): Nodemon; | ||||||||||
on(event: 'exit', listener: (e?: NodemonEventExit) => void): Nodemon; | ||||||||||
on( | ||||||||||
event: 'config:update', | ||||||||||
listener: (e?: NodemonEventConfig) => void | ||||||||||
): Nodemon; | ||||||||||
|
||||||||||
// this is repeated because VS Code doesn't autocomplete otherwise | ||||||||||
addEventListener(event: 'start' | 'crash', listener: () => void): Nodemon; | ||||||||||
addEventListener( | ||||||||||
event: 'log', | ||||||||||
listener: (e: NodemonEventLog) => void | ||||||||||
): Nodemon; | ||||||||||
addEventListener( | ||||||||||
event: 'restart', | ||||||||||
listener: (e?: NodemonEventRestart) => void | ||||||||||
): Nodemon; | ||||||||||
addEventListener( | ||||||||||
event: 'quit', | ||||||||||
listener: (e?: NodemonEventQuit) => void | ||||||||||
): Nodemon; | ||||||||||
addEventListener( | ||||||||||
event: 'exit', | ||||||||||
listener: (e?: NodemonEventExit) => void | ||||||||||
): Nodemon; | ||||||||||
addEventListener( | ||||||||||
event: 'config:update', | ||||||||||
listener: (e?: NodemonEventConfig) => void | ||||||||||
): Nodemon; | ||||||||||
|
||||||||||
once(event: 'start' | 'crash', listener: () => void): Nodemon; | ||||||||||
once(event: 'log', listener: (e: NodemonEventLog) => void): Nodemon; | ||||||||||
once(event: 'restart', listener: (e?: NodemonEventRestart) => void): Nodemon; | ||||||||||
once(event: 'quit', listener: (e?: NodemonEventQuit) => void): Nodemon; | ||||||||||
once(event: 'exit', listener: (e?: NodemonEventExit) => void): Nodemon; | ||||||||||
once( | ||||||||||
event: 'config:update', | ||||||||||
listener: (e?: NodemonEventConfig) => void | ||||||||||
): Nodemon; | ||||||||||
|
||||||||||
removeAllListeners(event: NodemonEventHandler): Nodemon; | ||||||||||
emit(type: NodemonEventHandler, event?: any): Nodemon; | ||||||||||
reset(callback: Function): Nodemon; | ||||||||||
restart(): Nodemon; | ||||||||||
config: NodemonSettings; | ||||||||||
}; | ||||||||||
|
||||||||||
type NodemonEventLog = { | ||||||||||
/** | ||||||||||
detail*: what you get with nodemon --verbose. | ||||||||||
status: subprocess starting, restarting. | ||||||||||
fail: is the subprocess crashing. | ||||||||||
error: is a nodemon system error. | ||||||||||
*/ | ||||||||||
type: 'detail' | 'log' | 'status' | 'error' | 'fail'; | ||||||||||
/** the plain text message */ | ||||||||||
message: String; | ||||||||||
/** contains the terminal escape codes to add colour, plus the "[nodemon]" prefix */ | ||||||||||
colour: String; | ||||||||||
}; | ||||||||||
|
||||||||||
interface NodemonEventRestart { | ||||||||||
matched?: { | ||||||||||
result: string[]; | ||||||||||
total: number; | ||||||||||
}; | ||||||||||
} | ||||||||||
|
||||||||||
type NodemonEventQuit = 143 | 130; | ||||||||||
type NodemonEventExit = number; | ||||||||||
|
||||||||||
// TODO: Define the type of NodemonEventConfig | ||||||||||
type NodemonEventConfig = any; | ||||||||||
|
||||||||||
interface NodemonSettings { | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could add the jsdoc from the old |
||||||||||
/* restartable defaults to "rs" as a string the user enters */ | ||||||||||
restartable?: false | String; | ||||||||||
colours?: Boolean; | ||||||||||
Comment on lines
+107
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be the primitive types, not the object wrappers.
Suggested change
|
||||||||||
execMap?: { [key: string]: string }; | ||||||||||
ignoreRoot?: string[]; | ||||||||||
watch?: string[]; | ||||||||||
stdin?: boolean; | ||||||||||
runOnChangeOnly?: boolean; | ||||||||||
verbose?: boolean; | ||||||||||
signal?: string; | ||||||||||
stdout?: boolean; | ||||||||||
watchOptions?: WatchOptions; | ||||||||||
} | ||||||||||
|
||||||||||
interface WatchOptions { | ||||||||||
ignorePermissionErrors: boolean; | ||||||||||
ignored: string; | ||||||||||
persistent: boolean; | ||||||||||
usePolling: boolean; | ||||||||||
interval: number; | ||||||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"compilerOptions": { | ||
"typeRoots": ["./index.d.ts", "./node_modules/@types"], | ||
"checkJs": true | ||
}, | ||
"exclude": ["node_modules"] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.