We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
In the PM2 documentation it has an example of how to use tx2.action:
tx2.action
tx2.action('world', function(param, reply) { console.log(param) reply({success : param}) })
But this doesn't match any of the documented call signatures in the documentation for tx2:
tx2
tx2.action('run_query', (cb) => { cb({ success: true }) }) tx2.action('run_query', arg1, (cb) => { cb({ success: arg1 }) })
The TypeScript typings for this package, available in https://github.com/DefinitelyTyped/DefinitelyTyped/, only allow usage as documented:
action(action_name: string, callback: (cb: (data: any) => void) => void): void; action<T extends object>( action_name: string, options: T, callback: (options: T, cb: (data: any) => void) => void, ): void;
(see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/tx2/index.d.ts#L36)
Thus this TypeScript code is invalid, even though when I run it as JS it works.
tx2.action(job.name, (param, reply) => { reply(param) });
The documentation and typings need to be updated if this is a supported use-case as the PM2 docs would suggest.
CC @sasial-dev
The text was updated successfully, but these errors were encountered:
My current workaround is thus:
type Tx2Action = (name: string, handler: (param: any, reply: (result: any) => void) => void) => void; const action = tx2.action.bind(tx2) as Tx2Action; action(job.name, (param, reply) => { reply(param); });
Those are some pretty nasty typings though... way too many nested function types. Perhaps something like this would be better:
type ActionCallback = (result: any) => void; type ActionHandlerNoParam = (reply: ActionCallback) => void; type ActionHandlerWithParam = (param: string, reply: ActionCallback) => void; type ActionHandler = ActionHandlerNoParam | ActionHandlerWithParam; export type Tx2Action = (name: string, handler: ActionHandler) => void;
Sorry, something went wrong.
Also CC @zoernert - looks like your PR #7 may be related?
No branches or pull requests
In the PM2 documentation it has an example of how to use
tx2.action
:But this doesn't match any of the documented call signatures in the documentation for
tx2
:The TypeScript typings for this package, available in https://github.com/DefinitelyTyped/DefinitelyTyped/, only allow usage as documented:
(see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/tx2/index.d.ts#L36)
Thus this TypeScript code is invalid, even though when I run it as JS it works.
The documentation and typings need to be updated if this is a supported use-case as the PM2 docs would suggest.
CC @sasial-dev
The text was updated successfully, but these errors were encountered: