Skip to content

Commit c4eb50a

Browse files
authored
Fix types of shorthand constructors (#1028)
1 parent 7c44225 commit c4eb50a

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

src/core/Ros.ts

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -762,22 +762,45 @@ export default class Ros extends EventEmitter<
762762
},
763763
);
764764
}
765-
Topic(options) {
766-
return new Topic({ ros: this, ...options });
765+
Topic<T>(options: Omit<ConstructorParameters<typeof Topic<T>>[0], "ros">) {
766+
return new Topic<T>({ ros: this, ...options });
767767
}
768-
Param(options) {
769-
return new Param({ ros: this, ...options });
768+
Param<T>(options: Omit<ConstructorParameters<typeof Param<T>>[0], "ros">) {
769+
return new Param<T>({ ros: this, ...options });
770770
}
771-
Service(options) {
772-
return new Service({ ros: this, ...options });
771+
Service<TRequest, TResponse>(
772+
options: Omit<
773+
ConstructorParameters<typeof Service<TRequest, TResponse>>[0],
774+
"ros"
775+
>,
776+
) {
777+
return new Service<TRequest, TResponse>({ ros: this, ...options });
773778
}
774-
TFClient(options) {
779+
TFClient(options: Omit<ConstructorParameters<typeof TFClient>[0], "ros">) {
775780
return new TFClient({ ros: this, ...options });
776781
}
777-
ActionClient(options) {
778-
return new ActionClient({ ros: this, ...options });
782+
ActionClient<TGoal, TFeedback, TResult>(
783+
options: Omit<
784+
ConstructorParameters<typeof ActionClient<TGoal, TFeedback, TResult>>[0],
785+
"ros"
786+
>,
787+
) {
788+
return new ActionClient<TGoal, TFeedback, TResult>({
789+
ros: this,
790+
...options,
791+
});
779792
}
780-
SimpleActionServer(options) {
781-
return new SimpleActionServer({ ros: this, ...options });
793+
SimpleActionServer<TGoal, TFeedback, TResult>(
794+
options: Omit<
795+
ConstructorParameters<
796+
typeof SimpleActionServer<TGoal, TFeedback, TResult>
797+
>[0],
798+
"ros"
799+
>,
800+
) {
801+
return new SimpleActionServer<TGoal, TFeedback, TResult>({
802+
ros: this,
803+
...options,
804+
});
782805
}
783806
}

0 commit comments

Comments
 (0)